Do you build things with AMP? Fill out the new AMP Developer Survey!



Provides zooming and panning for arbitrary content.

Required Scripts

<script async custom-element="amp-pan-zoom" src=""></script>

Supported Layouts


The <amp-pan-zoom> component takes one child of arbitrary content and enables the ability for the user to zoom and pan the content via double tap or pinch-to-zoom actions. Tap events registered on the zoomable content or its children will trigger after a 300ms delay.


<amp-layout layout="responsive" width="4" height="3">
  <amp-pan-zoom layout="fill">


max-scale (optional) Specifies a max zoom scale, which should be a positive number from 1 - 9. The default value is 3.
initial-scale (optional) Specifies a default zoom scale, which should be a positive number from 1 - 9. The default value is 1.
initial-x, initial-y (optional) Specifies default translation coordinates, otherwise both are set to 0. The value is expected to be a whole number.
reset-on-resize (optional) Refers to the ability to center the image and set the image's scale back to 1. Setting this attribute causes the component to reset the zoomable content on resize of the image itself.
controls (optional) Shows default controls (zoom in / zoom out button) which can be customized via public CSS classes.
common attributes This element includes common attributes extended to AMP components.

Events and actions

transformEnd (event)

The <amp-pan-zoom> component triggers the transformEnd event whenever the pan or zoom animation is complete. This event emits the scale, x, and y parameters. The scale parameter contains the current scale of the child content being zoomed. The x and y parameters contain the x and y translation of the child content from center in pixels, respectively.


This example contains an amp-pan-zoom component that will update amp-state on transformEnd.

<amp-state id="transform">
  <script type="application/json">
      "scale": 1,
      "y": 0,
      "x": 0
  [text]="'Current scale: ' + transform.scale + ', x: ' + transform.x + ', y: ' + transform.y"
  Current scale: 1
  on="transformEnd:AMP.setState({transform: {scale: event.scale, x: event.x, y: event.y}})"

transform (action)

The transform action takes scale, x, y as parameters and sets the CSS transform property of the child content. If no x or y value is specified, the content zooms to center.


Assuming that there is an <amp-pan-zoom> component with the id pan-zoom on the page, a button with on="tap:pan-zoom.transform(scale=3)" will zoom to scale 3x at the center of the content, a button with on="tap:pan-zoom.transform(scale=3, x=50, y=10)" will first scale the content to 3x scale, and then shift the content 50 pixels towards the left, and 10 pixels upwards. Consider the scale, x, and y attributes directly applied to the content's CSS transform attribute after animation.

Customizing Buttons

The following public CSS classes are exposed to allow customization for the zoom buttons:

.amp-pan-zoom-button .amp-pan-zoom-in-icon .amp-pan-zoom-out-icon;

Use .amp-pan-zoom-button to customize the dimensions, positioning, background-color, border-radius of all buttons. Use .amp-pan-zoom-in-icon to customize the icon for the zoom in button. Use .amp-pan-zoom-out-icon to customize the icon for the zoom out button. You can also hide these buttons entirely and create your own using the transform action. To hide them, just apply

.amp-pan-zoom-button {
  display: none;


See amp-pan-zoom rules in the AMP validator specification.

Eligibile children tags

See the list of eligibles children tags of amp-pan-zoom.

Besoin d'une aide supplémentaire ?

Vous avez lu ce document une douzaine de fois mais il ne répond pas à toutes vos questions ? D'autres personnes ont peut-être eu le même sentiment. Contactez-les sur Stack Overflow.

Se rendre sur Stack Overflow
Vous avez trouvé un bug ou une fonctionnalité manquante ?

Le projet AMP encourage fortement votre participation et vos contributions ! Nous espérons que vous deviendrez un membre régulier de notre communauté open source, mais nous serons également ravis de recevoir des contributions ponctuelles concernant les questions qui vous intéressent particulièrement.

Se rendre sur GitHub