1 | <template>
|
2 | <div
|
3 | id="z-container"
|
4 | class="z-canvas"
|
5 | :class="[classes, $zircle.getTheme(), $zircle.getThemeMode()]"
|
6 | :style="[$zircle.getPreviousViewName() !== '' ? {cursor: 'zoom-out'} : {}]"
|
7 | @click.stop="goback">
|
8 | <div id="z-zoomable-layer" ref="zoom" :style="zoom" @transitionend="notify">
|
9 | <z-view-manager />
|
10 | </div>
|
11 | </div>
|
12 | </template>
|
13 | <script>
|
14 |
|
15 | import ZViewManager from './child-components/z-view-manager'
|
16 | export default {
|
17 | name: 'z-canvas',
|
18 | props: {
|
19 | views: {
|
20 | type: [Object],
|
21 | required: true
|
22 | }
|
23 | },
|
24 | components: {
|
25 | ZViewManager
|
26 | },
|
27 | computed: {
|
28 | zoom () {
|
29 | var pos = {}
|
30 | this.$zircle.getHistoryLength() === 0 ? pos = { X: 0, Y: 0, Xi: 0, Yi: 0, scale: 1, scalei: 1 } : pos = this.$zircle.getCurrentPosition()
|
31 | return {
|
32 | transform: 'scale(' + pos.scale + ') translate3d(' + pos.Xi + 'px, ' + pos.Yi + 'px, 0px)',
|
33 | transition: 'transform 1000ms ease-in-out'
|
34 | }
|
35 | },
|
36 | classes () {
|
37 | return {
|
38 | 'is-full-mode': this.$zircle.getAppMode() === 'full',
|
39 | 'is-mixed-mode': this.$zircle.getAppMode() === 'mixed'
|
40 | }
|
41 | }
|
42 | },
|
43 | methods: {
|
44 | notify () {
|
45 | this.$zircle.setNavigationMode('iddle')
|
46 | },
|
47 | goback () {
|
48 | if (this.$zircle.getPreviousViewName() !== '' && this.$zircle.getBackwardNavigationState() === false && this.$zircle.getRouterState() === false) {
|
49 | this.$zircle.goBack()
|
50 | } else if (this.$zircle.getPreviousViewName() !== '' && this.$zircle.getBackwardNavigationState() === false && this.$zircle.getRouterState() === true) {
|
51 | this.$zircle.setNavigationMode('backward')
|
52 | this.$router.back()
|
53 | }
|
54 | }
|
55 | },
|
56 | created () {
|
57 | this.$zircle.setComponentList(this.views)
|
58 | },
|
59 | mounted () {
|
60 | var vm = this
|
61 |
|
62 | this.$nextTick()
|
63 | .then(function () {
|
64 |
|
65 | vm.$zircle.getDimensions()
|
66 | })
|
67 | window.addEventListener('resize', function (event) {
|
68 |
|
69 | vm.$zircle.getDimensions()
|
70 | })
|
71 | document.onmouseleave = function () {
|
72 |
|
73 | vm.$zircle.setNavigationMode('backward')
|
74 | }
|
75 | }
|
76 | }
|
77 | </script>
|
78 | <style lang="sass">
|
79 | @import '../styles/sass/themes.sass', '../styles/sass/styles.sass'
|
80 | </style>
|