JavaScript Element gestureend Event

Beginner
5 min read
Updated: Nov 2026
3 examples
Event

Definition

In JavaScript, the gestureend event fires when there are no longer multiple fingers contacting the touch surface, thus ending the gesture (MDN). It is a proprietary WebKit event. The event object is a GestureEvent (with scale and rotation).

Register a listener with addEventListener. Check readiness and browser support before you rely on this event.

Syntax

Listen for gestureend. Start with this line.

JavaScript
el.addEventListener("gestureend", fn)
CallWhat it does
el.addEventListener("gestureend", fn)Primary signature.

Built into the browser. Listen with el.addEventListener("gestureend", …) — no import required.

Library declarations
JavaScript
el.addEventListener("gestureend", fn)

Parameters

ParameterDescription
WebKit / SafariRequired. Only engine that implements it
Prior multi-touchRequired. Fires when multiple fingers are no longer down
GestureEventRequired. Final scale and rotation

Return Value

Return ValueDescription
*Fires as an Element event (listener receives the Event object).

JavaScript Examples

Example 1 — Feature Detect

Check WebKit gesture support before attaching end listeners.

JavaScript
const hasGesture =
  "ongestureend" in window ||
  typeof GestureEvent !== "undefined";

console.log("gestureend supported:", hasGesture);

if (!hasGesture) {
  console.log("Use touchend / pointerup instead");
}
Try It Yourself

How It Works

  1. Probe the globals. ongestureend or GestureEvent signal WebKit support.
  2. Branch early. Skip this event when unsupported.
  3. Plan a fallback. Commit pinch state on touchend instead.
  4. Optional enhancement. Only then attach gestureend on Safari.

Example 2 — Commit Final Scale

Use gestureend to lock in the last scale / rotation.

JavaScript
const el = document.getElementById("stage");
let lastScale = 1;

el.addEventListener("gesturechange", (event) => {
  lastScale = event.scale;
  console.log("live scale:", lastScale);
});

el.addEventListener("gestureend", (event) => {
  console.log("gestureend — commit scale:", event.scale);
  console.log("rotation:", event.rotation);
  // persist lastScale into your model / CSS
});

console.log("Listeners attached (needs Safari multi-touch)");
Try It Yourself

How It Works

  1. Track live values. gesturechange updates while fingers move.
  2. Listen for end. gestureend means multi-touch finished (MDN).
  3. Read finals. Commit event.scale / rotation to your UI state.
  4. Expect silence elsewhere. Non-WebKit browsers will not fire this event.

Example 3 — Portable End (touchend)

Cross-browser sketch: commit when fewer than two touches remain.

JavaScript
const el = document.getElementById("stage");
let startDist = 0;
let lastScale = 1;

function distance(a, b) {
  return Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY);
}

el.addEventListener("touchstart", (event) => {
  if (event.touches.length === 2) {
    startDist = distance(event.touches[0], event.touches[1]);
  }
});

el.addEventListener("touchmove", (event) => {
  if (event.touches.length === 2 && startDist) {
    lastScale = distance(event.touches[0], event.touches[1]) / startDist;
  }
});

el.addEventListener("touchend", (event) => {
  if (event.touches.length < 2 && startDist) {
    console.log("commit scale:", lastScale.toFixed(3));
    startDist = 0;
  }
});
Try It Yourself

How It Works

  1. Track two touches. Store start distance, update scale on move.
  2. On touchend. When fewer than two fingers remain, treat that as “gesture end”.
  3. Commit once. Persist lastScale and reset the start distance.
  4. Optional Safari. You may still listen for gestureend where available.

Browser Support

Element gestureend is Non-standard on MDN (WebKit proprietary). It is not Deprecated or Experimental. Not Baseline — Safari/iOS focused.

✓ Non-standard · WebKit

Element gestureend

Fires when multi-touch ends. GestureEvent still exposes final scale and rotation.

WebKit Safari / related WebKit
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Android WebView Supported · Modern WebView
Full support
gestureend Non-standard

Bottom line: Treat as Safari learning / optional enhancement. Ship touchend or pointerup commit logic for cross-browser pinch.

Frequently Asked Questions

It is a proprietary WebKit event fired when there are no longer multiple fingers contacting the touch surface, thus ending the gesture (MDN). The event object is a GestureEvent. MDN marks it Non-standard.
MDN marks Element gestureend as Non-standard only — not Deprecated and not Experimental. Still avoid it as the primary API in cross-browser production apps.
gesturestart begins the gesture, gesturechange fires while digits move, and gestureend fires when the multi-touch gesture finishes.
It is WebKit-specific. Expect Safari on iOS (and related WebKit contexts). Chrome, Firefox, and Edge generally do not implement this event.
They report the final GestureEvent values for that gesture: scale relative to the start distance, and rotation in degrees since the gesture began (MDN GestureEvent).
For portable pinch/zoom, prefer Touch Events or Pointer Events and commit when the second finger lifts (for example touchend). Feature-detect GestureEvent only as an optional Safari enhancement.

Next: gesturestart

Learn the WebKit event that fires when a multi-touch gesture begins.

gesturestart tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful