diff options
author | julieng <julien.gattelier@gmail.com> | 2021-10-02 17:20:24 +0200 |
---|---|---|
committer | SphinxKnight <SphinxKnight@users.noreply.github.com> | 2021-10-02 17:30:20 +0200 |
commit | 1407c8fdef01ecd0ffb8a8bd46e7113f119b9fde (patch) | |
tree | 30a56efd3eff3a01bd1611e1840fdbbfacf544a4 /files/fr/web/api/performanceelementtiming/naturalwidth/index.md | |
parent | c05efa8d7ae464235cf83d7c0956e42dc6974103 (diff) | |
download | translated-content-1407c8fdef01ecd0ffb8a8bd46e7113f119b9fde.tar.gz translated-content-1407c8fdef01ecd0ffb8a8bd46e7113f119b9fde.tar.bz2 translated-content-1407c8fdef01ecd0ffb8a8bd46e7113f119b9fde.zip |
convert content to md
Diffstat (limited to 'files/fr/web/api/performanceelementtiming/naturalwidth/index.md')
-rw-r--r-- | files/fr/web/api/performanceelementtiming/naturalwidth/index.md | 71 |
1 files changed, 32 insertions, 39 deletions
diff --git a/files/fr/web/api/performanceelementtiming/naturalwidth/index.md b/files/fr/web/api/performanceelementtiming/naturalwidth/index.md index 3e254d3289..1843a6a58f 100644 --- a/files/fr/web/api/performanceelementtiming/naturalwidth/index.md +++ b/files/fr/web/api/performanceelementtiming/naturalwidth/index.md @@ -10,54 +10,47 @@ tags: - PerformanceElementTiming translation_of: Web/API/PerformanceElementTiming/naturalWidth --- -<div>{{APIRef("Element Timing API")}}</div> +{{APIRef("Element Timing API")}} -<p>La propriété en lecture seule <strong><code>naturalWidth</code></strong> de l'interface <a href="/fr/docs/Web/API/PerformanceElementTiming"><code>PerformanceElementTiming</code></a> renvoie la largeur intrinsèque de l'élément image.</p> -<h2 id="Syntax">Syntax</h2> +La propriété en lecture seule **`naturalWidth`** de l'interface [`PerformanceElementTiming`](/fr/docs/Web/API/PerformanceElementTiming) renvoie la largeur intrinsèque de l'élément image. -<pre class="brush:js">var <var>width</var> = <var>PerformanceElementTiming</var>.naturalWidth;</pre> +## Syntax -<h3>Valeur</h3> -<p>Un entier de 32 bits non signé (<i>unsigned long</i>) qui est la largeur intrinsèque de l'image si cela est appliqué à une image, 0 pour le texte.</p> +```js +var width = PerformanceElementTiming.naturalWidth; +``` -<h2 id="Examples">Exemples</h2> +### Valeur -<p>Dans cet exemple, le fichier image a une largeur de 1000px et une hauteur de 750px. L'appel de <code>entry.naturalWidth</code> renvoie <code>1000</code>, c'est-à-dire la largeur intrinsèque en pixels.</p> +Un entier de 32 bits non signé (_unsigned long_) qui est la largeur intrinsèque de l'image si cela est appliqué à une image, 0 pour le texte. -<pre class="brush:html"><img src="image.jpg" alt="une belle image" elementtiming="big-image" id="myImage"></pre> +## Exemples -<pre class="brush:js">const <var>observer</var> = new PerformanceObserver((list) => { - let <var>entries</var> = list.getEntries().forEach(function (entry) { +Dans cet exemple, le fichier image a une largeur de 1000px et une hauteur de 750px. L'appel de `entry.naturalWidth` renvoie `1000`, c'est-à-dire la largeur intrinsèque en pixels. + +```html +<img src="image.jpg" alt="une belle image" elementtiming="big-image" id="myImage"> +``` + +```js +const observer = new PerformanceObserver((list) => { + let entries = list.getEntries().forEach(function (entry) { if (entry.identifier === "big-image") { console.log(entry.naturalWidth); } }); }); -observer.observe({ entryTypes: ["element"] });</pre> - -<div class="note"> - <p><strong>Note :</strong> Cet exemple utilise l'interface <a href="/fr/docs/Web/API/PerformanceObserver"><code>PerformanceObserver</code></a> pour créer une liste d'événements de mesure des performances. Dans notre cas, nous observons l'élément <a href="/fr/docs/Web/API/PerformanceEntry/entryType"><code>PerformanceEntry.entryType</code></a> afin d'utiliser l'interface <code>PerformanceElementTiming</code>.</p> -</div> - -<h2 id="Specifications">Specifications</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Spécification</th> - <th scope="col">Statut</th> - <th scope="col">Commentaire</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('Element Timing API','#dom-performanceelementtiming-naturalwidth','PerformanceElementTiming.naturalWidth')}}</td> - <td>{{Spec2('Element Timing API')}}</td> - <td>Définition initiale.</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">Compatibilité des navigateurs</h2> - -<p>{{Compat("api.PerformanceElementTiming.naturalWidth")}}</p> +observer.observe({ entryTypes: ["element"] }); +``` + +> **Note :** Cet exemple utilise l'interface [`PerformanceObserver`](/fr/docs/Web/API/PerformanceObserver) pour créer une liste d'événements de mesure des performances. Dans notre cas, nous observons l'élément [`PerformanceEntry.entryType`](/fr/docs/Web/API/PerformanceEntry/entryType) afin d'utiliser l'interface `PerformanceElementTiming`. + +## Specifications + +| Spécification | Statut | Commentaire | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- | -------------------- | +| {{SpecName('Element Timing API','#dom-performanceelementtiming-naturalwidth','PerformanceElementTiming.naturalWidth')}} | {{Spec2('Element Timing API')}} | Définition initiale. | + +## Compatibilité des navigateurs + +{{Compat("api.PerformanceElementTiming.naturalWidth")}} |