XRSession.cancelAnimationFrame()

Draft
This page is not complete.

Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The cancelAnimationFrame() method of the XRSession interface cancels an animation frame previously requested via a call to XRSession.requestAnimationFrame.

Note: Your callback routine must itself call requestAnimationFrame if you want to animate another frame at the next repaint.

Syntax

XRSession.cancelAnimationFrame(handle);

Parameters

handle
The long value previously returned by the call to XRSession.requestAnimationFrame that scheduled the animation callback.

Return value

None.

Example

// Obtain XR object
const XR = navigator.xr

let handle = null
let xrSession = null

function renderFrame(){
  // Frame update logic
}

function frameCallback (time, xrFrame) {
  // Schedule the next callback
  handle = xrSession.requestAnimationFrame(frameCallback)
  // Update logic
  renderFrame()
}

// Request a new XRSession
XR.requestSession("immersive-vr").then((xrSession) => {
  // XR session started
  handle = xrSession.requestAnimationFrame(frameCallback)
})

function stop(){
  xrSession.cancelAnimationFrame(handle)
}

Specifications

Specification Status Comment
WebXR Device API
The definition of 'XRSession.cancelAnimationFrame' in that specification.
Working Draft Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
cancelAnimationFrame()Chrome No support NoEdge No support NoFirefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support No

Legend

No support  
No support

See also

Document Tags and Contributors

Contributors to this page: jpmedley, bershanskiy
Last updated by: jpmedley,