Skip to content

Commit

Permalink
Close #1124 virtual-tour: add showLoader transition option
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Oct 26, 2023
1 parent ec3e401 commit b5c102d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
8 changes: 7 additions & 1 deletion docs/plugins/virtual-tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ Enable the preloading of linked nodes, can be a function that returns true or fa
#### `transitionOptions`

- type: `object | function`
- default: `{ speed: '20rpm', fadeIn: true, rotation: true }`
- default: `{ showLoader: true, speed: '20rpm', fadeIn: true, rotation: true }`
- updatable: no

Configuration of the transition between nodes. Can be a callback.
Expand All @@ -404,6 +404,11 @@ The default behaviour is to rotate the view to face the direction of the link an

```ts
{
/**
* Show the loader while loading the new panorama
* @default true
*/
showLoader?: boolean;
/**
* Speed or duration of the transition between nodes
* @default '20rpm'
Expand All @@ -426,6 +431,7 @@ The default behaviour is to rotate the view to face the direction of the link an

```ts
(toNode: Node, fromNode?: Node, fromLink?: NodeLink) => ({
showLoader?: boolean;
speed?: string | number;
fadeIn?: boolean;
rotation?: boolean;
Expand Down
1 change: 1 addition & 0 deletions examples/plugin-virtual-tour.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
preload: true,
arrowPosition: 'bottom',
transitionOptions: {
// showLoader: false,
// speed: '10rpm',
// fadeIn: false,
// rotation: false,
Expand Down
10 changes: 6 additions & 4 deletions packages/virtual-tour-plugin/src/VirtualTourPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const getConfig = utils.getConfigParser<VirtualTourPluginConfig>(
startNodeId: null,
preload: false,
transitionOptions: {
showLoader: true,
speed: '20rpm',
fadeIn: true,
rotation: true,
Expand Down Expand Up @@ -393,9 +394,7 @@ export class VirtualTourPlugin extends AbstractConfigurablePlugin<
}

const transitionOptions: VirtualTourTransitionOptions = {
speed: (getConfig.defaults.transitionOptions as any).speed,
fadeIn: (getConfig.defaults.transitionOptions as any).fadeIn,
rotation: (getConfig.defaults.transitionOptions as any).rotation,
...getConfig.defaults.transitionOptions,
rotateTo: fromLinkPosition,
...(typeof this.config.transitionOptions === 'function'
? this.config.transitionOptions(node, fromNode, fromLink)
Expand All @@ -419,7 +418,9 @@ export class VirtualTourPlugin extends AbstractConfigurablePlugin<
throw utils.getAbortError();
}

this.viewer.loader.show();
if (transitionOptions.showLoader) {
this.viewer.loader.show();
}

this.state.currentNode = node;

Expand All @@ -443,6 +444,7 @@ export class VirtualTourPlugin extends AbstractConfigurablePlugin<
panoData: node.panoData,
sphereCorrection: node.sphereCorrection,
transition: !transitionOptions.fadeIn ? false : transitionOptions.rotation ? true : 'fade-only',
showLoader: transitionOptions.showLoader,
speed: transitionOptions.speed,
position: transitionOptions.rotateTo,
zoom: transitionOptions.zoomTo,
Expand Down
9 changes: 7 additions & 2 deletions packages/virtual-tour-plugin/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ export type VirtualTourMarkerStyle = Omit<
* Behaviour of the transition between nodes
*/
export type VirtualTourTransitionOptions = {
/**
* Show the loader while loading the new panorama
* @default true
*/
showLoader?: boolean;
/**
* Speed or duration of the transition between nodes
* @default '20rpm'
Expand Down Expand Up @@ -216,10 +221,10 @@ export type VirtualTourPluginConfig = {

/**
* Configuration of the transition between nodes. Can be a callback.
* @default `{ speed: '20rpm', fadeIn: true, rotation: true }`
* @default `{ showLoader: true, speed: '20rpm', fadeIn: true, rotation: true }`
*/
transitionOptions?:
| Pick<VirtualTourTransitionOptions, 'speed' | 'fadeIn' | 'rotation'>
| Pick<VirtualTourTransitionOptions, 'showLoader' | 'speed' | 'fadeIn' | 'rotation'>
| ((
toNode: VirtualTourNode,
fromNode?: VirtualTourNode,
Expand Down

0 comments on commit b5c102d

Please sign in to comment.