extensions/amp-story-360/0.1/amp-story-360.js
/**
   * Listens for deviceorientation events.
   *
   * Some browsers support the 'deviceorientation' event but never call it.
   * This waits for one call before initiating a constant listener.
   * @private
   */
Listens for deviceorientation events.
Some browsers support the 'deviceorientation' event but never call it.
This waits for one call before initiating a constant listener.
@private
Listens for deviceorientation events . Some browsers support the ' deviceorientation ' event but never call it . This waits for one call before initiating a constant listener . @private
enableGyroscope_() {
    listenOncePromise(this.win, 'deviceorientation').then((e) => {
      this.gyroscopeControls_ = true;
      this.orientationAlpha_ = e.alpha;
      this.maybeSetGyroscopeDefaultHeading_();
      let rafTimeout;
      this.win.addEventListener('deviceorientation', (e) => {
        this.orientationAlpha_ = e.alpha;
        if (this.isReady_ && this.isOnActivePage_) {
          rafTimeout && this.win.cancelAnimationFrame(rafTimeout);
          rafTimeout = this.win.requestAnimationFrame(() =>
            this.onDeviceOrientation_(e)
          );
        }
      });
      this.maybeShowDiscoveryAnimation_();
    });
  }
enableGyroscope_ ( ) { listenOncePromise ( this . win , 'deviceorientation' ) . then ( ( e ) => { this . gyroscopeControls_ = true ; this . orientationAlpha_ = e . alpha ; this . maybeSetGyroscopeDefaultHeading_ ( ) ; let rafTimeout ; this . win . addEventListener ( 'deviceorientation' , ( e ) => { this . orientationAlpha_ = e . alpha ; if ( this . isReady_ && this . isOnActivePage_ ) { rafTimeout && this . win . cancelAnimationFrame ( rafTimeout ) ; rafTimeout = this . win . requestAnimationFrame ( ( ) => this . onDeviceOrientation_ ( e ) ) ; } } ) ; this . maybeShowDiscoveryAnimation_ ( ) ; } ) ; }
Listens for deviceorientation events.
Listens for deviceorientation events .
// Listen for one call before initiating. // Debounce onDeviceOrientation_ to rAF. // Used to set default heading when navigating to this page.