Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 750925 of SVGPreserveAspectRatio

  • Revision slug: Web/API/SVGPreserveAspectRatio
  • Revision title: SVGPreserveAspectRatio
  • Revision id: 750925
  • Created:
  • Creator: fscholz
  • Is current revision? Yes
  • Comment

Revision Content

{{APIRef("SVG")}}

SVG preserveAspectRatio interface

The SVGPreserveAspectRatio interface corresponds to the {{ SVGAttr("preserveAspectRatio") }} attribute, which is available for some of SVG's elements.

An SVGPreserveAspectRatio object can be designated as read only, which means that attempts to modify the object will result in an exception being thrown.

Interface overview

Also implement None
Methods None
Properties
  • unsigned short align
  • unsigned short meetOrSlice
Constants
  • SVG_PRESERVEASPECTRATIO_UNKNOWN = 0
  • SVG_PRESERVEASPECTRATIO_NONE = 1
  • SVG_PRESERVEASPECTRATIO_XMINYMIN = 2
  • SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3
  • SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4
  • SVG_PRESERVEASPECTRATIO_XMINYMID = 5
  • SVG_PRESERVEASPECTRATIO_XMIDYMID = 6
  • SVG_PRESERVEASPECTRATIO_XMAXYMID = 7
  • SVG_PRESERVEASPECTRATIO_XMINYMAX = 8
  • SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9
  • SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10
  • SVG_MEETORSLICE_UNKNOWN = 0
  • SVG_MEETORSLICE_MEET = 1
  • SVG_MEETORSLICE_SLICE = 2
Normative document SVG 1.1 (2nd Edition)

Constants

Name Value Description
SVG_PRESERVEASPECTRATIO_UNKNOWN 0 The enumeration was set to a value that is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.
SVG_PRESERVEASPECTRATIO_NONE 1 Corresponds to value none for attribute {{ SVGAttr("preserveAspectRatio") }}.
SVG_PRESERVEASPECTRATIO_XMINYMIN 2 Corresponds to value xMinYMin for attribute {{ SVGAttr("preserveAspectRatio") }}.
SVG_PRESERVEASPECTRATIO_XMIDYMIN 3 Corresponds to value xMidYMin for attribute {{ SVGAttr("preserveAspectRatio") }}.
SVG_PRESERVEASPECTRATIO_XMAXYMIN 4 Corresponds to value xMaxYMin for attribute {{ SVGAttr("preserveAspectRatio") }}.
SVG_PRESERVEASPECTRATIO_XMINYMID 5 Corresponds to value xMinYMid for attribute {{ SVGAttr("preserveAspectRatio") }}.
SVG_PRESERVEASPECTRATIO_XMIDYMID 6 Corresponds to value xMidYMid for attribute {{ SVGAttr("preserveAspectRatio") }}.
SVG_PRESERVEASPECTRATIO_XMAXYMID 7 Corresponds to value xMaxYMid for attribute {{ SVGAttr("preserveAspectRatio") }}.
SVG_PRESERVEASPECTRATIO_XMINYMAX 8 Corresponds to value xMinYMax for attribute {{ SVGAttr("preserveAspectRatio") }}.
SVG_PRESERVEASPECTRATIO_XMIDYMAX 9 Corresponds to value xMidYMax for attribute {{ SVGAttr("preserveAspectRatio") }}.
SVG_PRESERVEASPECTRATIO_XMAXYMAX 10 Corresponds to value xMaxYMax for attribute {{ SVGAttr("preserveAspectRatio") }}.
SVG_MEETORSLICE_UNKNOWN 0 The enumeration was set to a value that is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.
SVG_MEETORSLICE_MEET 1 Corresponds to value meet for attribute {{ SVGAttr("preserveAspectRatio") }}.
SVG_MEETORSLICE_SLICE 2 Corresponds to value slice for attribute {{ SVGAttr("preserveAspectRatio") }}.

Properties

Name Type Description
align unsigned short The type of the alignment value as specified by one of the SVG_PRESERVEASPECTRATIO_* constants defined on this interface.
meetOrSlice unsigned short The type of the meet-or-slice value as specified by one of the SVG_MEETORSLICE_* constants defined on this interface.

Exceptions on setting: a DOMException with code NO_MODIFICATION_ALLOWED_ERR is raised on an attempt to change the value of an attribute on a read only object.

Methods

The SVGPreserveAspectRatio interface do not provide any specific methods.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

 

Revision Source

<div>{{APIRef("SVG")}}</div>

<h2 id="SVG_preserveAspectRatio_interface">SVG preserveAspectRatio interface</h2>

<p>The <code>SVGPreserveAspectRatio</code> interface corresponds to the {{ SVGAttr("preserveAspectRatio") }} attribute, which is available for some of SVG's elements.</p>

<p>An <code>SVGPreserveAspectRatio</code> object can be designated as read only, which means that attempts to modify the object will result in an exception being thrown.</p>

<h3 id="Interface_overview">Interface overview</h3>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="row">Also&nbsp;implement</th>
   <td><em>None</em></td>
  </tr>
  <tr>
   <th scope="row">Methods</th>
   <td><em>None</em></td>
  </tr>
  <tr>
   <th scope="row">Properties</th>
   <td>
    <ul>
     <li>unsigned short <code>align</code></li>
     <li>unsigned short <code>meetOrSlice</code></li>
    </ul>
   </td>
  </tr>
  <tr>
   <th scope="row">Constants</th>
   <td>
    <ul>
     <li><code>SVG_PRESERVEASPECTRATIO_UNKNOWN</code> = 0</li>
     <li><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_NONE</code> = 1</li>
     <li><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_XMINYMIN</code> = 2</li>
     <li><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_</code><code>XMIDYMIN</code> = 3</li>
     <li><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_</code><code>XMAXYMIN</code> = 4</li>
     <li><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_</code><code>XMINYMID</code> = 5</li>
     <li><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_</code><code>XMIDYMID</code> = 6</li>
     <li><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_</code><code>XMAXYMID</code> = 7</li>
     <li><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_</code><code>XMINYMAX</code> = 8</li>
     <li><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_</code><code>XMIDYMAX</code> = 9</li>
     <li><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_</code><code>XMAXYMAX</code> = 10</li>
    </ul>

    <ul>
     <li><code>SVG_MEETORSLICE_UNKNOWN</code> = 0</li>
     <li><code>SVG_</code><code>MEETORSLICE</code><code>_MEET</code> = 1</li>
     <li><code>SVG_</code><code>MEETORSLICE</code><code>_SLICE</code> = 2</li>
    </ul>
   </td>
  </tr>
  <tr>
   <th scope="row">Normative&nbsp;document</th>
   <td><a class="external" href="https://www.w3.org/TR/SVG/coords.html#InterfaceSVGPreserveAspectRatio" title="https://www.w3.org/TR/SVG/coords.html#InterfaceSVGPreserveAspectRatio">SVG 1.1 (2nd Edition)</a></td>
  </tr>
 </tbody>
</table>

<h2 id="Constants">Constants</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th>Name</th>
   <th>Value</th>
   <th>Description</th>
  </tr>
  <tr>
   <td><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_UNKNOWN</code></td>
   <td>0</td>
   <td>The enumeration was set to a value that is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.</td>
  </tr>
  <tr>
   <td><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_NONE</code></td>
   <td>1</td>
   <td>Corresponds to value <code>none</code> for attribute {{ SVGAttr("preserveAspectRatio") }}.</td>
  </tr>
  <tr>
   <td><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_XMINYMIN</code></td>
   <td>2</td>
   <td>Corresponds to value <code>xMinYMin</code> for attribute {{ SVGAttr("preserveAspectRatio") }}.</td>
  </tr>
  <tr>
   <td><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_XMIDYMIN</code></td>
   <td>3</td>
   <td>Corresponds to value <code>xMidYMin</code> for attribute {{ SVGAttr("preserveAspectRatio") }}.</td>
  </tr>
  <tr>
   <td><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_XMAXYMIN</code></td>
   <td>4</td>
   <td>Corresponds to value <code>xMaxYMin</code> for attribute {{ SVGAttr("preserveAspectRatio") }}.</td>
  </tr>
  <tr>
   <td><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_XMINYMID</code></td>
   <td>5</td>
   <td>Corresponds to value <code>xMinYMid</code> for attribute {{ SVGAttr("preserveAspectRatio") }}.</td>
  </tr>
  <tr>
   <td><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_XMIDYMID</code></td>
   <td>6</td>
   <td>Corresponds to value <code>xMidYMid</code> for attribute {{ SVGAttr("preserveAspectRatio") }}.</td>
  </tr>
  <tr>
   <td><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_XMAXYMID</code></td>
   <td>7</td>
   <td>Corresponds to value <code>xMaxYMid</code> for attribute {{ SVGAttr("preserveAspectRatio") }}.</td>
  </tr>
  <tr>
   <td><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_XMINYMAX</code></td>
   <td>8</td>
   <td>Corresponds to value <code>xMinYMax</code> for attribute {{ SVGAttr("preserveAspectRatio") }}.</td>
  </tr>
  <tr>
   <td><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_XMIDYMAX</code></td>
   <td>9</td>
   <td>Corresponds to value <code>xMidYMax</code> for attribute {{ SVGAttr("preserveAspectRatio") }}.</td>
  </tr>
  <tr>
   <td><code>SVG_</code><code>PRESERVEASPECTRATIO</code><code>_XMAXYMAX</code></td>
   <td>10</td>
   <td>Corresponds to value <code>xMaxYMax</code> for attribute {{ SVGAttr("preserveAspectRatio") }}.</td>
  </tr>
  <tr>
   <td><code>SVG_MEETORSLICE_UNKNOWN</code></td>
   <td>0</td>
   <td>The enumeration was set to a value that is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.</td>
  </tr>
  <tr>
   <td><code>SVG_MEETORSLICE_MEET</code></td>
   <td>1</td>
   <td>Corresponds to value <code>meet</code> for attribute {{ SVGAttr("preserveAspectRatio") }}.</td>
  </tr>
  <tr>
   <td><code>SVG_MEETORSLICE_SLICE</code></td>
   <td>2</td>
   <td>Corresponds to value <code>slice</code> for attribute {{ SVGAttr("preserveAspectRatio") }}.</td>
  </tr>
 </tbody>
</table>

<h2 id="Properties">Properties</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th>Name</th>
   <th>Type</th>
   <th>Description</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td><code>align</code></td>
   <td>unsigned&nbsp;short</td>
   <td>The type of the alignment value as specified by one of the SVG_PRESERVEASPECTRATIO_* constants defined on this interface.</td>
  </tr>
  <tr>
   <td><code>meetOrSlice</code></td>
   <td>unsigned&nbsp;short</td>
   <td>The type of the meet-or-slice value as specified by one of the SVG_MEETORSLICE_* constants defined on this interface.</td>
  </tr>
 </tbody>
</table>

<p><strong>Exceptions on setting:</strong> a <code><a href="DOMException" rel="custom">DOMException</a></code> with code <code>NO_MODIFICATION_ALLOWED_ERR</code> is raised on an attempt to change the value of an attribute on a read only object.</p>

<h2 id="Methods">Methods</h2>

<p>The <code>SVGPreserveAspectRatio</code> interface do not provide any specific methods.</p>

<h2 id="Browser_compatibility" name="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>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</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>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
  </tr>
 </tbody>
</table>
</div>

<p>&nbsp;</p>
Revert to this revision