UNPKG

photo-sphere-viewer

Version:

A JavaScript library to display Photo Sphere panoramas

63 lines (53 loc) 1.3 kB
import { EVENTS } from '../data/constants'; import playActive from '../icons/play-active.svg'; import play from '../icons/play.svg'; import { AbstractButton } from './AbstractButton'; /** * @summary Navigation bar autorotate button class * @extends PSV.buttons.AbstractButton * @memberof PSV.buttons */ export class AutorotateButton extends AbstractButton { static id = 'autorotate'; static icon = play; static iconActive = playActive; /** * @param {PSV.components.Navbar} navbar */ constructor(navbar) { super(navbar, 'psv-button--hover-scale psv-autorotate-button', true); this.psv.on(EVENTS.AUTOROTATE, this); } /** * @override */ destroy() { this.psv.off(EVENTS.AUTOROTATE, this); super.destroy(); } /** * @summary Handles events * @param {Event} e * @private */ handleEvent(e) { /* eslint-disable */ switch (e.type) { // @formatter:off case EVENTS.AUTOROTATE: this.toggleActive(e.args[0]); break; // @formatter:on } /* eslint-enable */ } /** * @override * @description Toggles autorotate */ onClick() { if (this.psv.isAutorotateEnabled()) { this.psv.config.autorotateIdle = false; this.psv.resetIdleTimer(); } this.psv.toggleAutorotate(); } }