Skip to content

Commit

Permalink
Close #1449 virtual-tour: compat with autorotate
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Oct 2, 2024
1 parent fddc34d commit b211023
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/autorotate-plugin/src/AutorotateButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class AutorotateButton extends AbstractButton {

onClick() {
if (this.plugin.isEnabled()) {
this.plugin.config.autostartOnIdle = false;
this.plugin.disableOnIdle();
}
this.plugin.toggle();
}
Expand Down
11 changes: 10 additions & 1 deletion packages/autorotate-plugin/src/AutorotatePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class AutorotatePlugin extends AbstractConfigurablePlugin<

private readonly state = {
initialStart: true,
disableOnIdle: false,
/** if the automatic rotation is enabled */
enabled: false,
/** current index in keypoints */
Expand Down Expand Up @@ -259,6 +260,7 @@ export class AutorotatePlugin extends AbstractConfigurablePlugin<
}

this.state.initialStart = false;
this.state.disableOnIdle = false;
this.state.enabled = true;

this.dispatchEvent(new AutorotateEvent(true));
Expand Down Expand Up @@ -305,6 +307,13 @@ export class AutorotatePlugin extends AbstractConfigurablePlugin<
}
}

/**
* @internal
*/
disableOnIdle() {
this.state.disableOnIdle = true;
}

/**
* Launches the standard animation
*/
Expand Down Expand Up @@ -363,7 +372,7 @@ export class AutorotatePlugin extends AbstractConfigurablePlugin<
*/
private __beforeRender(timestamp: number) {
if (
(this.state.initialStart || this.config.autostartOnIdle)
(this.state.initialStart || this.config.autostartOnIdle && !this.state.disableOnIdle)
&& this.viewer.state.idleTime > 0
&& timestamp - this.viewer.state.idleTime > this.config.autostartDelay
) {
Expand Down
2 changes: 2 additions & 0 deletions packages/virtual-tour-plugin/src/VirtualTourPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ export class VirtualTourPlugin extends AbstractConfigurablePlugin<
})
);

this.viewer.resetIdleTimer();

return true;
})
.catch((err) => {
Expand Down

0 comments on commit b211023

Please sign in to comment.