UNPKG

5.21 kBPlain TextView Raw
1<template>
2 <div
3 class="z-shape primary"
4 :class="[componentType]"
5 :style="responsive === true ? styles.main : zpos.main"
6 style="overflow: visible;"
7 @animationend="notify"
8 @mouseover = "$zircle.allowBackwardNavigation(true)"
9 @mouseleave = "$zircle.allowBackwardNavigation(false)">
10 <div :id="fullView" v-if="$slots['image'] || imagePath" class="z-content">
11 <img v-if="imagePath" :src="imagePath" width="100%" height="100%" />
12 <slot v-if="!imagePath" name="image"></slot>
13 </div>
14 <section style="opacity: 0" :style="animation">
15 <div class="z-outer-circle" :style="responsive === true ? styles.plate : zpos.plate"></div>
16 <z-scroll v-if="scrollBar" :scrollVal.sync="scrollVal" style="overflow: visible;"/>
17 <z-slider v-if="slider === true" :progress='progress'/>
18 <div v-if="label" class="z-label" :class="labelPos">
19 <div class="inside">
20 {{label}}
21 </div>
22 </div>
23 <div class="z-content maincontent" ref="maincontent" :class="[longContent, firefoxScroll]" @scroll.passive="scroll">
24 <div ref="ztext">
25 <slot></slot>
26 </div>
27 </div>
28 <div v-if="$slots['media']" class="z-content" style="z-index: 60">
29 <slot name="media" ></slot>
30 </div>
31 <slot name="extension"></slot>
32 </section>
33 </div>
34</template>
35
36<script>
37import ZSlider from './child-components/z-slider'
38import ZScroll from './child-components/z-scroll'
39export default {
40 name: 'z-view',
41 props: {
42 distance: {
43 type: Number,
44 default: 0
45 },
46 angle: {
47 type: Number,
48 default: 0
49 },
50 size: {
51 type: String,
52 default: 'xxl'
53 },
54 label: {
55 type: [String, Number]
56 },
57 labelPos: {
58 type: [String],
59 default: 'bottom'
60 },
61 imagePath: {
62 type: [String]
63 },
64 progress: {
65 type: Number,
66 default: 0
67 },
68 slider: {
69 type: [Boolean],
70 default: false
71 }
72 },
73 components: {
74 ZScroll,
75 ZSlider
76 },
77 data () {
78 return {
79 componentType: this.$options.name,
80 scrollVal: -45,
81 zpos: {},
82 isMounted: false,
83 ffox: false,
84 fullView: this.$zircle.getNavigationMode() === 'forward' ? this.$zircle.getCurrentViewName() : this.$zircle.getPastViewName()
85 }
86 },
87 provide () {
88 return {
89 view: this.fullView
90 }
91 },
92 computed: {
93 position () {
94 return this.$zircle.calcViewPosition(this.fullView)
95 },
96 scrollBar () {
97 var isScrollNeeded = false
98 if (this.isMounted === true && this.fullView === this.$zircle.getCurrentViewName() && this.$refs.ztext.clientHeight > this.$zircle.getComponentWidth(this.size)) {
99 isScrollNeeded = true
100 }
101 return isScrollNeeded
102 },
103 responsive () {
104 if (this.fullView === this.$zircle.getCurrentViewName()) {
105 // eslint-disable-next-line
106 this.zpos = this.styles
107 return true
108 } else {
109 return false
110 }
111 },
112 styles () {
113 var width = this.$zircle.getComponentWidth(this.size)
114 return {
115 main: {
116 width: width + 'px',
117 height: width + 'px',
118 margin: -(width / 2) + 'px 0 0 ' + -(width / 2) + 'px',
119 transform: 'translate3d(' + this.position.X + 'px, ' + this.position.Y + 'px, 0px) scale(' + this.position.scalei + ')'
120 },
121 plate: {
122 width: width + 75 + 'px',
123 height: width + 75 + 'px',
124 margin: -((width + 75) / 2) + 'px 0 0 ' + -((width + 75) / 2) + 'px'
125 }
126 }
127 },
128 animation () {
129 if (this.fullView === this.$zircle.getCurrentViewName() && this.$zircle.getNavigationMode() === 'forward') {
130 var zstyle = 'opacity: 1; transition: opacity 1000ms linear;'
131 } else if (this.fullView === this.$zircle.getCurrentViewName() && this.$zircle.getNavigationMode() !== 'forward') {
132 zstyle = 'opacity: 1;'
133 } else {
134 zstyle = 'opacity: 0; transition: opacity 500ms linear;'
135 }
136 return zstyle
137 },
138 longContent () {
139 return {
140 'long-content': this.scrollBar === true
141 }
142 },
143 firefoxScroll () {
144 return {
145 'z-scroll-disabled-for-firefox': this.scrollBar === true && this.ffox === true
146 }
147 }
148 },
149 methods: {
150 notify () {
151 if (this.$zircle.getHistoryLength() === 1) this.$zircle.setNavigationMode('iddle')
152 },
153 scroll () {
154 if (this.scrollBar === true) {
155 var container = this.$refs.maincontent
156 this.scrollVal = -45 + ((container.scrollTop * 100 / (container.scrollHeight - container.clientHeight)) * 86 / 100)
157 }
158 }
159 },
160 watch: {
161 scrollVal () {
162 if (this.scrollBar === true) {
163 var container = this.$refs.maincontent
164 container.scrollTop = ((45 + this.scrollVal) * 100 / 86) * (container.scrollHeight - container.clientHeight) / 100
165 }
166 }
167 },
168 mounted () {
169 if (navigator.userAgent.match('Firefox')) {
170 this.$zircle.setLog('Firefox desktop detected. Scroll events disabled')
171 this.ffox = true
172 }
173 this.zpos = this.styles
174 var vm = this
175 setTimeout(function () {
176 vm.isMounted = true
177 }, 1000)
178 }
179}
180</script>