diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:45 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:45 -0500 |
| commit | 1109132f09d75da9a28b649c7677bb6ce07c40c0 (patch) | |
| tree | 0dd8b084480983cf9f9680e8aedb92782a921b13 /files/es/web/api/mediaquerylist | |
| parent | 4b1a9203c547c019fc5398082ae19a3f3d4c3efe (diff) | |
| download | translated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.tar.gz translated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.tar.bz2 translated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.zip | |
initial commit
Diffstat (limited to 'files/es/web/api/mediaquerylist')
| -rw-r--r-- | files/es/web/api/mediaquerylist/addlistener/index.html | 148 | ||||
| -rw-r--r-- | files/es/web/api/mediaquerylist/index.html | 178 | ||||
| -rw-r--r-- | files/es/web/api/mediaquerylist/matches/index.html | 108 | ||||
| -rw-r--r-- | files/es/web/api/mediaquerylist/removelistener/index.html | 149 |
4 files changed, 583 insertions, 0 deletions
diff --git a/files/es/web/api/mediaquerylist/addlistener/index.html b/files/es/web/api/mediaquerylist/addlistener/index.html new file mode 100644 index 0000000000..e52d1b8b33 --- /dev/null +++ b/files/es/web/api/mediaquerylist/addlistener/index.html @@ -0,0 +1,148 @@ +--- +title: MediaQueryList.addListener() +slug: Web/API/MediaQueryList/addListener +translation_of: Web/API/MediaQueryList/addListener +--- +<div>{{APIRef("CSSOM View")}}</div> + +<div>El método <code><strong>addListener()</strong></code> de la interfaz {{domxref ("MediaQueryList")}} añade un escucha al <code>MediaQueryListener</code> que ejecutará una función de devolución de llamada personalizada en respuesta al cambio de estado de consulta de medios.<br> + </div> + +<div> +<p>Esto es básicamente un alias para {{domxref("EventTarget.addEventListener()")}}, para propósitos de compatibilidad con versiones anteriores: en los navegadores antiguos se puede usar <code>addEventListener.</code></p> +</div> + +<h2 id="Sintaxis">Sintaxis</h2> + +<pre class="syntaxbox"><em>MediaQueryList.addListener(func)</em></pre> + +<h3 id="Parametros">Parametros</h3> + +<dl> + <dt>func</dt> + <dd>A function or function reference representing the callback function you want to run when the media query status changes. In the original implementation, the callback was a non-standard {{domxref("MediaQueryListListener")}} object. In the new implementation the standard event mechanism is used, the callback is a standard function, and the event object is a {{domxref("MediaQueryListEvent")}}, which inherits from {{domxref("Event")}}.</dd> +</dl> + +<h3 id="Return_value">Return value</h3> + +<p>Void.</p> + +<h2 id="Examples">Examples</h2> + +<pre class="brush: js">var mql = window.matchMedia('(max-width: 600px)'); + +function screenTest(e) { + if (e.matches) { + /* the viewport is 600 pixels wide or less */ + para.textContent = 'This is a narrow screen — less than 600px wide.'; + document.body.style.backgroundColor = 'red'; + } else { + /* the viewport is more than than 600 pixels wide */ + para.textContent = 'This is a wide screen — more than 600px wide.'; + document.body.style.backgroundColor = 'blue'; + } +} + +mql.addListener(screenTest);</pre> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th>Specification</th> + <th>Status</th> + <th>Comment</th> + </tr> + <tr> + <td>{{SpecName("CSSOM View", "#dom-mediaquerylist-addlistener", "addListener")}}</td> + <td>{{Spec2("CSSOM View")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>9</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoDesktop("6.0")}}</td> + <td>10</td> + <td>12.1</td> + <td>5</td> + </tr> + <tr> + <td>New version spec update</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoDesktop("55")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Edge</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + <th>Chrome for Android</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + <tr> + <td>New version spec update</td> + <td>{{CompatNo}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoMobile("55")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="See_also">See also</h2> + +<ul> + <li><a href="/en-US/docs/CSS/Media_queries">Media queries</a></li> + <li><a href="/en-US/docs/CSS/Using_media_queries_from_code">Using media queries from code</a></li> + <li>{{domxref("window.matchMedia()")}}</li> + <li>{{domxref("MediaQueryList")}}</li> + <li>{{domxref("MediaQueryListEvent")}}</li> +</ul> diff --git a/files/es/web/api/mediaquerylist/index.html b/files/es/web/api/mediaquerylist/index.html new file mode 100644 index 0000000000..a13b29cdbb --- /dev/null +++ b/files/es/web/api/mediaquerylist/index.html @@ -0,0 +1,178 @@ +--- +title: MediaQueryList +slug: Web/API/MediaQueryList +tags: + - API + - CSSOM Vista + - CompatibilidadDeNavegadores + - Interface + - MediaQueryList + - Refetencia +translation_of: Web/API/MediaQueryList +--- +<div>{{APIRef("CSSOM View")}}{{SeeCompatTable}}</div> + +<p>Un objeto <code>MediaQueryList</code> almacena información en un <a href="/en-US/docs/Web/CSS/Media_Queries">media query</a> aplicada a un documento y se encarga de enviar notificaciones a los oyentes cuando cambia el estado de consulta de medios (es decir, cuando la prueba de consulta de medios comienza o deja de evaluarse a <code>true</code>).</p> + +<p>Esto hace posible observar un documento para detectar cuando sus consultas de medios cambian, en lugar de sondear los valores periódicamente y le permite programar cambios en un documento basado en el estado de consulta de medios.</p> + +<h2 id="Propiedades">Propiedades</h2> + +<p>La nueva versión de la interfaz de <em><code>MediaQueryList</code> </em> hereda las propiedades de su interfaz principal, <em>{{domxref("EventTarget")}}.</em></p> + +<dl> + <dt>{{domxref("MediaQueryList.matches")}} {{readonlyInline}}</dt> + <dd> Un {{domxref("Boolean")}} que devuelve <code>true</code> si el<br> + {{domxref("document")}} actualmente coincide con la lista de consultas de medios, o <code>false</code> si no.</dd> + <dt>{{domxref("MediaQueryList.media")}} {{readonlyInline}}</dt> + <dd> Un {{domxref("DOMString")}} representa una consulta de medios serializada.</dd> +</dl> + +<h3 id="Controladores_de_eventos">Controladores de eventos</h3> + +<dl> + <dt>{{domxref("MediaQueryList.onchange")}}</dt> + <dd>Una propiedad de controlador de eventos que representa una función que se invoca cuando se desencadena el evento {{event("change")}}, es decir, cuando cambia el estado del soporte de consulta de medios. El objeto de evento es una instancia {{domxref("MediaQueryListEvent")}}, que se reconoce como una instancia de <code>MediaListQuery</code> en navegadores antiguos, para propósitos de compatibilidad con versiones anteriores.</dd> +</dl> + +<h2 id="Métodos">Métodos</h2> + +<p><em>La nueva versión de la interfaz de <code>MediaQueryList</code> hereda métodos de su interfaz principal, {{domxref("EventTarget")}}.</em></p> + +<dl> + <dt>{{domxref("MediaQueryList.addListener()")}}</dt> + <dd> Agrega un escucha al <code>MediaQueryListener</code> que ejecutará una función de devolución de llamada personalizada en respuesta al cambio de estado de consulta de medios. Esto es básicamente un alias para {{domxref("EventTarget.addEventListener()")}}, para propósitos de compatibilidad con versiones anteriores. </dd> + <dt>{{domxref("MediaQueryList.removeListener()")}}</dt> + <dd> Elimina un escucha de <code>MediaQueryListener</code>. Esto es básicamente un alias para {{domxref ("EventTarget.removeEventListener ()")}}, para propósitos de compatibilidad con versiones anteriores.</dd> +</dl> + +<dl> +</dl> + +<h2 id="Ejemplos">Ejemplos</h2> + +<p>Este ejemplo sencillo crea una <code>MediaQueryList</code> y, a continuación, establece un detector para detectar cuándo cambia el estado de la consulta de medios, ejecutando una función personalizada cuando cambia la apariencia de la página.</p> + +<pre class="brush: js">var para = document.querySelector('p'); + +var mql = window.matchMedia('(max-width: 600px)'); + +function screenTest(e) { + if (e.matches) { + /* el ventana tiene 600 píxeles de ancho o menos*/ + para.textContent = 'This is a narrow screen — less than 600px wide.'; + document.body.style.backgroundColor = 'red'; + } else { + /* la ventana tiene más de 600 píxeles de ancho */ + para.textContent = 'This is a wide screen — more than 600px wide.'; + document.body.style.backgroundColor = 'blue'; + } +} + +mql.addListener(screenTest);</pre> + +<div class="note"> +<p><strong>Nota</strong>: Puedes encontrar este ejemplo en GitHub (ver el <a href="https://github.com/mdn/dom-examples/blob/master/mediaquerylist/index.html">codigo fuente</a>, y también verlo en <a href="https://mdn.github.io/dom-examples/mediaquerylist/index.html">ejecución</a>).</p> +</div> + +<h2 id="Especificaciones">Especificaciones</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th>Especificaciones</th> + <th>Estado</th> + <th>Comentario</th> + </tr> + <tr> + <td>{{SpecName("CSSOM View", "#the-mediaquerylist-interface", "MediaQueryList")}}</td> + <td>{{Spec2("CSSOM View")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilidad_del_navegador">Compatibilidad del navegador</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>9</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoDesktop("6.0")}}</td> + <td>10</td> + <td>12.1</td> + <td>5</td> + </tr> + <tr> + <td>New version spec update</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoDesktop("55")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Edge</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + <th>Chrome for Android</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + <tr> + <td>New version spec update</td> + <td>{{CompatNo}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoMobile("55")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="Ver_también">Ver también</h2> + +<ul> + <li><a href="/en-US/docs/CSS/Media_queries">Media queries</a></li> + <li><a href="/en-US/docs/CSS/Using_media_queries_from_code">Uso de media queries desde el código</a></li> + <li>{{domxref("window.matchMedia()")}}</li> + <li>{{domxref("MediaQueryListListener")}}</li> + <li>{{domxref("MediaQueryListEvent")}}</li> +</ul> diff --git a/files/es/web/api/mediaquerylist/matches/index.html b/files/es/web/api/mediaquerylist/matches/index.html new file mode 100644 index 0000000000..c31f6fa707 --- /dev/null +++ b/files/es/web/api/mediaquerylist/matches/index.html @@ -0,0 +1,108 @@ +--- +title: MediaQueryList.matches +slug: Web/API/MediaQueryList/matches +translation_of: Web/API/MediaQueryList/matches +--- +<div>{{APIRef("CSSOM View")}}</div> + +<p>La propiedad <strong><code>matches</code> </strong>de sólo lectura de la interfaz {{domxref ("MediaQueryList")}} es {{domxref ("Boolean")}} que devuelve <code>true</code> si el {{domxref ("document")}} coincide actualmente con el medio lista de consultas, o <code>false</code> si no.</p> + +<h2 id="Sintaxis">Sintaxis</h2> + +<pre class="syntaxbox">var <em>matches</em> = <em>MediaQueryList.matches;</em></pre> + +<h3 id="Value">Value</h3> + +<p>A {{domxref("Boolean")}}; returns <code>true</code> if the {{domxref("document")}} currently matches the media query list, <code>false</code> if not.</p> + +<h2 id="Examples">Examples</h2> + +<pre class="brush: js">var mql = window.matchMedia('(max-width: 600px)'); + +if(mql.matches) { + // media query test returning true +} +</pre> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th>Specification</th> + <th>Status</th> + <th>Comment</th> + </tr> + <tr> + <td>{{SpecName("CSSOM View", "#dom-mediaquerylist-matches", "matches")}}</td> + <td>{{Spec2("CSSOM View")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>9</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoDesktop("6.0")}}</td> + <td>10</td> + <td>12.1</td> + <td>5</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Edge</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + <th>Chrome for Android</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="See_also">See also</h2> + +<ul> + <li><a href="/en-US/docs/CSS/Media_queries">Media queries</a></li> + <li><a href="/en-US/docs/CSS/Using_media_queries_from_code">Using media queries from code</a></li> + <li>{{domxref("window.matchMedia()")}}</li> + <li>{{domxref("MediaQueryList")}}</li> + <li>{{domxref("MediaQueryListEvent")}}</li> +</ul> diff --git a/files/es/web/api/mediaquerylist/removelistener/index.html b/files/es/web/api/mediaquerylist/removelistener/index.html new file mode 100644 index 0000000000..2689dde854 --- /dev/null +++ b/files/es/web/api/mediaquerylist/removelistener/index.html @@ -0,0 +1,149 @@ +--- +title: MediaQueryList.removeListener() +slug: Web/API/MediaQueryList/removeListener +translation_of: Web/API/MediaQueryList/removeListener +--- +<div>{{APIRef("CSSOM View")}}</div> + +<p>El método <code><strong>removeListener()</strong></code> de la interfaz {{domxref ("MediaQueryList")}} elimina un escucha de <code>MediaQueryListener</code>.</p> + +<p>Esto es básicamente un alias para {{domxref("EventTarget.removeEventListener()")}}, para propósitos de compatibilidad con versiones anteriores: en los navegadores antiguos puede usar <code>removeEventListener()</code>.</p> + +<h2 id="Sintaxis">Sintaxis</h2> + +<pre class="syntaxbox"><em>MediaQueryList.removeListener(func)</em></pre> + +<h3 id="Parametros">Parametros</h3> + +<dl> + <dt>func</dt> + <dd>Una función o referencia de función que representa la función de devolución de llamada que desea eliminar. En la implementación original, la devolución de llamada era un objeto {{domxref ("MediaQueryListListener")}} no estándar. En la nueva implementación se utiliza el mecanismo de eventos estándar y la devolución de llamada es una función estándar.</dd> +</dl> + +<h3 id="Return_value">Return value</h3> + +<p>Void.</p> + +<h2 id="Ejemplos">Ejemplos</h2> + +<pre class="brush: js">var mql = window.matchMedia('(max-width: 600px)'); + +function screenTest(e) { + if (e.matches) { + /* the viewport is 600 pixels wide or less */ + para.textContent = 'This is a narrow screen — less than 600px wide.'; + document.body.style.backgroundColor = 'red'; + } else { + /* the viewport is more than than 600 pixels wide */ + para.textContent = 'This is a wide screen — more than 600px wide.'; + document.body.style.backgroundColor = 'blue'; + } +} + +mql.addListener(screenTest); + +// Later on, when it is no longer needed +mql.removeListener(screenTest); +</pre> + +<h2 id="Especificaciones">Especificaciones</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th>Especificaciones</th> + <th>Estado</th> + <th>Comentario</th> + </tr> + <tr> + <td>{{SpecName("CSSOM View", "#dom-mediaquerylist-removelistener", "removeListener")}}</td> + <td>{{Spec2("CSSOM View")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilidad_del_navegador">Compatibilidad del navegador</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>9</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoDesktop("6.0")}}</td> + <td>10</td> + <td>12.1</td> + <td>5</td> + </tr> + <tr> + <td>New version spec update</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoDesktop("55")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Edge</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + <th>Chrome for Android</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + <tr> + <td>New version spec update</td> + <td>{{CompatNo}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoMobile("55")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="Ver_también">Ver también</h2> + +<ul> + <li><a href="/en-US/docs/CSS/Media_queries">Media queries</a></li> + <li><a href="/en-US/docs/CSS/Using_media_queries_from_code">Using media queries from code</a></li> + <li>{{domxref("window.matchMedia()")}}</li> + <li>{{domxref("MediaQueryList")}}</li> + <li>{{domxref("MediaQueryListEvent")}}</li> +</ul> |
