blob: faf96a2b44884169e61500317be3484a20357fa1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
---
title: chargingchange
slug: Web/Events/chargingchange
translation_of: Archive/Events/chargingchange
---
<p>L'événement <code><strong>chargingchange</strong> est déclenché lorsque l'attribut <em>charging</em> de l'<a href="https://developer.mozilla.org/fr/docs/DOM/window.navigator.battery">API batterie</a> est modifié.</code></p>
<h2 id="Informations_générales">Informations générales</h2>
<dl>
<dt style="float: left; text-align: right; width: 120px;">Spécification</dt>
<dd style="margin: 0 0 0 120px;"><a class="external" href="http://www.w3.org/TR/battery-status/">Battery</a></dd>
<dt style="float: left; text-align: right; width: 120px;">Interface</dt>
<dd style="margin: 0 0 0 120px;">Event</dd>
<dt style="float: left; text-align: right; width: 120px;">Propagation</dt>
<dd style="margin: 0 0 0 120px;">Non</dd>
<dt style="float: left; text-align: right; width: 120px;">Annulable</dt>
<dd style="margin: 0 0 0 120px;">Non</dd>
<dt style="float: left; text-align: right; width: 120px;">Cible</dt>
<dd style="margin: 0 0 0 120px;">{{domxref("BatteryManager")}}</dd>
<dt style="float: left; text-align: right; width: 120px;">Action par défaut</dt>
<dd style="margin: 0 0 0 120px;">Aucune</dd>
</dl>
<h2 id="Properties" name="Properties">Propriétés</h2>
<p>Le callback de l'événement ne reçoit aucun objet événement, mais les propriétés peuvent être lues à partir de l'objet {{domxref("BatteryManager")}} reçu par la méthode {{domxref("navigator.getBattery")}}.</p>
<table class="standard-table">
<tbody>
<tr>
<td class="header">Property</td>
<td class="header">Type</td>
<td class="header">Description</td>
</tr>
<tr>
<td>{{domxref("BatteryManager.charging")}} {{readOnlyInline}}</td>
<td>boolean</td>
<td>Etat de charge de la batterie du système. Retourne true si la batterie est en chargement. Si l'état de la batterie du système est non-déterminé, aucune batterie n'est rattachée au système ou si si la batterie se décharge, retourne false.</td>
</tr>
</tbody>
</table>
<h2 id="Example" name="Example">Exemple</h2>
<pre class="brush: js">navigator.getBattery().then(function(battery) {
console.log("Battery charging? " + (battery.charging ? "Yes" : "No"));
battery.addEventListener('chargingchange', function() {
console.log("Battery charging? " + (battery.charging ? "Yes" : "No"));
});
});
</pre>
<h2 id="Evénements_liés">Evénements liés</h2>
<ul>
<li>{{Event("chargingtimechange")}}</li>
<li>{{Event("dischargingtimechange")}}</li>
<li>{{Event("levelchange")}}</li>
</ul>
|