forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSameElement.vue
More file actions
110 lines (95 loc) · 2.66 KB
/
SameElement.vue
File metadata and controls
110 lines (95 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<template>
<div class="q-pa-md q-gutter-y-md">
<div class="row no-wrap q-gutter-x-lg items-center relative-position">
<q-btn color="primary" no-wrap label="Morph element" @click="morphContent1" />
<div ref="firstMorphRef" v-bind="props1">
{{ toggle1 ? 'Small' : 'Large' }}
</div>
</div>
<div
class="row no-wrap q-gutter-x-lg items-center relative-position"
:class="{ 'justify-between': toggle2 }"
>
<q-btn color="primary" no-wrap label="Morph element" @click="morphContent2" />
<q-avatar ref="secondMorphRef" text-color="white" size="100px" v-bind="props2" />
</div>
</div>
</template>
<script>
import { morph } from 'quasar'
import { ref, computed } from 'vue'
export default {
setup () {
const toggle1 = ref(false)
const toggle2 = ref(false)
const firstMorphRef = ref(null)
const secondMorphRef = ref(null)
let cancel1, cancel2
return {
toggle1,
toggle2,
firstMorphRef,
secondMorphRef,
props1: computed(() => {
return toggle1.value === true
? {
class: 'q-ml-sm q-pa-md bg-orange text-white rounded-borders',
style: 'font-size: 24px'
}
: {
class: 'q-ml-xl q-px-xl q-py-lg bg-blue text-white',
style: 'border-radius: 25% 0/50% 0; font-size: 36px'
}
}),
props2: computed(() => {
return toggle2.value === true
? {
fontSize: '52px',
color: 'positive',
icon: 'check',
rounded: true
}
: {
fontSize: '32px',
color: 'negative',
icon: 'close'
}
}),
morphContent1 () {
const onToggle = () => {
toggle1.value = toggle1.value !== true
}
if (cancel1 === void 0 || cancel1() === false) {
cancel1 = morph({
from: firstMorphRef.value,
onToggle,
duration: 500,
tween: true,
onEnd: end => {
end === 'from' && onToggle()
}
})
}
},
morphContent2 () {
const onToggle = () => {
toggle2.value = toggle2.value !== true
}
if (cancel2 === void 0 || cancel2() === false) {
cancel2 = morph({
from: secondMorphRef.value.$el,
onToggle,
duration: 500,
tween: true,
tweenFromOpacity: 0.8,
tweenToOpacity: 0.4,
onEnd: end => {
end === 'from' && onToggle()
}
})
}
}
}
}
}
</script>