Skip to content

Commit 842dd85

Browse files
committed
Fix #1049 Fix #960 virtual-tour: add configurable behaviour
1 parent af7fc73 commit 842dd85

File tree

19 files changed

+586
-269
lines changed

19 files changed

+586
-269
lines changed

docs/.vuepress/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ module.exports = {
157157
},
158158
],
159159
['@vuepress/back-to-top'],
160-
require('./plugins/gallery'),
161160
require('./plugins/code-demo'),
161+
require('./plugins/dialog'),
162+
require('./plugins/gallery'),
162163
require('./plugins/module'),
163164
require('./plugins/tabs'),
164165
],
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<template>
2+
<div>
3+
<md-dialog :md-active.sync="showDialog">
4+
<md-dialog-title>{{ title }}</md-dialog-title>
5+
6+
<md-dialog-content class="theme-default-content">
7+
<slot></slot>
8+
</md-dialog-content>
9+
10+
<md-dialog-actions>
11+
<md-button class="md-primary md-raised" @click="showDialog = false">Close</md-button>
12+
</md-dialog-actions>
13+
</md-dialog>
14+
15+
<md-button class="md-primary md-raised" @click="showDialog = true">{{ button }}</md-button>
16+
</div>
17+
</template>
18+
19+
<script>
20+
export default {
21+
name: 'Dialog',
22+
data: () => ({
23+
showDialog: false
24+
}),
25+
props: {
26+
title: { type: String, default: '' },
27+
button: { type: String, default: '' },
28+
},
29+
};
30+
</script>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Dialog from './Dialog.vue';
2+
3+
export default ({ Vue }) => {
4+
Vue.component('Dialog', Dialog);
5+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const container = require('markdown-it-container');
2+
const path = require('path');
3+
4+
module.exports = (options, ctx) => ({
5+
name: 'dialog',
6+
enhanceAppFiles: path.resolve(__dirname, './enhanceApp.js'),
7+
extendMarkdown: (md) => {
8+
md.use(container, 'dialog', {
9+
render: (tokens, idx) => {
10+
const { nesting, info } = tokens[idx];
11+
12+
if (nesting === 1) {
13+
const [, button, title] = info.match(/dialog "(.*?)" "(.*?)"/);
14+
return `<Dialog button="${button}" title="${title}">\n`;
15+
} else {
16+
return `</Dialog>\n`;
17+
}
18+
},
19+
});
20+
},
21+
});

docs/.vuepress/plugins/gallery/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ module.exports = (options, ctx) => ({
1919

2020
md.use(container, 'item', {
2121
render: (tokens, idx) => {
22-
const { nesting, info } = tokens[idx];
23-
const attributes = info.trim().slice('item '.length);
22+
const { nesting } = tokens[idx];
2423

2524
if (nesting === 1) {
26-
return `<GalleryItem ${attributes}>\n`;
25+
return `<GalleryItem>\n`;
2726
} else {
2827
return `</GalleryItem>\n`;
2928
}

docs/.vuepress/styles/index.styl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
box-shadow: 0 2px 1px -1px rgba(0,0,0,.2),0 1px 1px 0 rgba(0,0,0,.14),0 1px 3px 0 rgba(0,0,0,.12);
1919
}
2020

21+
.md-dialog-content.theme-default-content {
22+
margin: 0;
23+
}
24+
.md-dialog-content p:first-child:not(:only-child) {
25+
margin-top: inherit;
26+
}
27+
.md-dialog-content p:last-child:not(:only-child) {
28+
margin-bottom: inherit;
29+
}
30+
2131
.site-name .md-badge {
2232
position: static;
2333
display: inline;

docs/guide/methods.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ It is good practice to wait for the `ready` event before calling any method.
1818
viewer.addEventListener('ready', () => {
1919
viewer.rotate({
2020
textureX: 1500,
21-
textureY: 1000
21+
textureY: 1000,
2222
});
2323
}, { once: true });
2424
```
@@ -29,7 +29,11 @@ This section describes the most useful methods available.
2929

3030
### `animate(options): Animation`
3131

32-
Rotate and zoom the view with a smooth animation. You can change the position (`yaw`, `pitch` or `textureX`, `textureY`) and the zoom level (`zoom`). The `speed` option is either a duration in milliseconds or a string containing the speed in revolutions per minute (`2rpm`). It returns a `Animation` object which is a standard Promise with an additional `cancel` method.
32+
Rotate and zoom the view with a smooth animation. You can change the position (`yaw`, `pitch` or `textureX`, `textureY`) and the zoom level (`zoom`).
33+
34+
The `speed` option is either a duration in milliseconds or a string containing the speed in revolutions per minute (`2rpm`).
35+
36+
The method returns a `Animation` object which is a standard Promise with an additional `cancel` method.
3337

3438
```js
3539
viewer.animate({
@@ -87,9 +91,22 @@ viewer.setOptions({
8791

8892
Change the panorama image with an optional transition animation (enabled by default). See all options in the <ApiLink page="types/Core.PanoramaOptions.html"/>.
8993

94+
The `speed` option is either a duration in milliseconds or a string containing the speed in revolutions per minute (`2rpm`).
95+
96+
The method returns a Promise resolved when the new panorama has finished loading.
97+
9098
```js
9199
viewer.setPanorama('image.jpg')
92100
.then(() => /* update complete */);
101+
102+
viewer.setPanorama('image.jpg', { transition: false });
103+
104+
viewer.setPanorama('image.jpg', {
105+
speed: '20rpm',
106+
position: { yaw: 0, pitch: 0 },
107+
caption: 'The new caption',
108+
// more options in the API doc
109+
});
93110
```
94111

95112
### `zoom(level)` | `zoomIn()` | `zoomOut()`

0 commit comments

Comments
 (0)