enableGyroscope_() {
    this.gyroscopeControls_ = true;
    this.togglePermissionClass_(true);

    const checkNoMotion = this.timer_.delay(() => {
      this.gyroscopeControls_ = false;
      if (this.isReady_ && this.isPlaying_) {
        this.animate_();
      }
    }, 1000);

    let rafTimeout;

    this.win.addEventListener('deviceorientation', (e) => {
      if (this.isReady_ && this.isOnActivePage_) {
        // Debounce onDeviceOrientation_ to rAF.
        rafTimeout && this.win.cancelAnimationFrame(rafTimeout);
        rafTimeout = this.win.requestAnimationFrame(() =>
          this.onDeviceOrientation_(e)
        );
      }
      this.timer_.cancel(checkNoMotion);
    });
  }
/**
   * Creates a device orientation listener and sets gyroscopeControls_ state.
   * If listener is not called in 1000ms, remove listener and resume animation.
   * This happens on desktop browsers that support deviceorientation but aren't in motion.
   * @private
   */
Creates a device orientation listener and sets gyroscopeControls_ state.
If listener is not called in 1000ms, remove listener and resume animation.
This happens on desktop browsers that support deviceorientation but aren't in motion.
@private
Creates a device orientation listener and sets gyroscopeControls_ state . If listener is not called in 1000ms remove listener and resume animation . This happens on desktop browsers that support deviceorientation but aren ' t in motion . @private
enableGyroscope_() {
    this.gyroscopeControls_ = true;
    this.togglePermissionClass_(true);
    const checkNoMotion = this.timer_.delay(() => {
      this.gyroscopeControls_ = false;
      if (this.isReady_ && this.isPlaying_) {
        this.animate_();
      }
    }, 1000);
    let rafTimeout;
    this.win.addEventListener('deviceorientation', (e) => {
      if (this.isReady_ && this.isOnActivePage_) {
        rafTimeout && this.win.cancelAnimationFrame(rafTimeout);
        rafTimeout = this.win.requestAnimationFrame(() =>
          this.onDeviceOrientation_(e)
        );
      }
      this.timer_.cancel(checkNoMotion);
    });
  }
enableGyroscope_ ( ) { this . gyroscopeControls_ = true ; this . togglePermissionClass_ ( true ) ; const checkNoMotion = this . timer_ . delay ( ( ) => { this . gyroscopeControls_ = false ; if ( this . isReady_ && this . isPlaying_ ) { this . animate_ ( ) ; } } , 1000 ) ; let rafTimeout ; this . win . addEventListener ( 'deviceorientation' , ( e ) => { if ( this . isReady_ && this . isOnActivePage_ ) { rafTimeout && this . win . cancelAnimationFrame ( rafTimeout ) ; rafTimeout = this . win . requestAnimationFrame ( ( ) => this . onDeviceOrientation_ ( e ) ) ; } this . timer_ . cancel ( checkNoMotion ) ; } ) ; }
Creates a device orientation listener and sets gyroscopeControls_ state.
Creates a device orientation listener and sets gyroscopeControls_ state .
// Debounce onDeviceOrientation_ to rAF.