@mixd-id/web-scaffold 0.1.2301231344 → 0.1.2301231345
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/Countdown.vue +82 -23
package/package.json
CHANGED
|
@@ -2,22 +2,33 @@
|
|
|
2
2
|
<div :class="$style.comp">
|
|
3
3
|
|
|
4
4
|
<slot v-if="display >= 4 && $slots.day" name="day" :day="day"></slot>
|
|
5
|
-
<div v-else-if="display >= 4" :class="$style.lap"
|
|
5
|
+
<div ref="day" v-else-if="display >= 4" :class="$style.lap">
|
|
6
|
+
<div></div>
|
|
7
|
+
<div></div>
|
|
8
|
+
</div>
|
|
6
9
|
|
|
7
10
|
<slot v-if="display >= 3 && $slots.hour" name="hour" :hour="hour"></slot>
|
|
8
|
-
<div v-else-if="display >= 3" :class="$style.lap">
|
|
11
|
+
<div ref="hour" v-else-if="display >= 3" :class="$style.lap">
|
|
12
|
+
<div></div>
|
|
13
|
+
<div></div>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div>:</div>
|
|
9
17
|
|
|
10
18
|
<slot v-if="display >= 2 && $slots.minute" name="minute" :minute="minute"></slot>
|
|
11
|
-
<div v-else-if="display >= 2" :class="$style.lap">
|
|
19
|
+
<div ref="minute" v-else-if="display >= 2" :class="$style.lap">
|
|
20
|
+
<div></div>
|
|
21
|
+
<div></div>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<div>:</div>
|
|
12
25
|
|
|
13
26
|
<slot v-if="display >= 1 && $slots.second" name="second" :second="second"></slot>
|
|
14
27
|
<div ref="second" v-else-if="display >= 1" :class="$style.lap">
|
|
15
|
-
<div
|
|
16
|
-
<div
|
|
28
|
+
<div></div>
|
|
29
|
+
<div></div>
|
|
17
30
|
</div>
|
|
18
31
|
|
|
19
|
-
<button @click="tick">Tick</button>
|
|
20
|
-
|
|
21
32
|
</div>
|
|
22
33
|
</template>
|
|
23
34
|
|
|
@@ -63,42 +74,67 @@ export default{
|
|
|
63
74
|
timer: null,
|
|
64
75
|
timeoutId: null,
|
|
65
76
|
beforeSecond: null,
|
|
66
|
-
afterSecond: null
|
|
77
|
+
afterSecond: null,
|
|
78
|
+
tick: false
|
|
67
79
|
}
|
|
68
80
|
},
|
|
69
81
|
|
|
70
82
|
mounted() {
|
|
71
83
|
this.start()
|
|
72
84
|
|
|
73
|
-
this.$refs.second.addEventListener('transitionend', this.
|
|
85
|
+
if(this.$refs.second) this.$refs.second.addEventListener('transitionend', this.onSecondEnd)
|
|
86
|
+
if(this.$refs.minute) this.$refs.minute.addEventListener('transitionend', this.onMinuteEnd)
|
|
87
|
+
if(this.$refs.hour) this.$refs.hour.addEventListener('transitionend', this.onHourEnd)
|
|
88
|
+
if(this.$refs.day) this.$refs.day.addEventListener('transitionend', this.onDayEnd)
|
|
74
89
|
},
|
|
75
90
|
|
|
76
91
|
methods: {
|
|
77
92
|
|
|
78
|
-
|
|
79
|
-
/*console.log('onTransitionEnd', e.propertyName)
|
|
80
|
-
console.log(this.$refs.second.childNodes[1])
|
|
81
|
-
console.log(this.$refs.second.childNodes[0])*/
|
|
93
|
+
onSecondEnd: debounce(function (e){
|
|
82
94
|
this.$refs.second.insertBefore(this.$refs.second.childNodes[1], this.$refs.second.childNodes[0])
|
|
83
95
|
this.$refs.second.classList.remove(this.$style.tick)
|
|
84
96
|
this.$refs.second.childNodes[0].innerHTML = ''
|
|
85
97
|
}, 100),
|
|
86
98
|
|
|
99
|
+
onMinuteEnd: debounce(function (e){
|
|
100
|
+
this.$refs.minute.insertBefore(this.$refs.minute.childNodes[1], this.$refs.minute.childNodes[0])
|
|
101
|
+
this.$refs.minute.classList.remove(this.$style.tick)
|
|
102
|
+
this.$refs.minute.childNodes[0].innerHTML = ''
|
|
103
|
+
}, 100),
|
|
104
|
+
|
|
105
|
+
onHourEnd: debounce(function (e){
|
|
106
|
+
this.$refs.hour.insertBefore(this.$refs.hour.childNodes[1], this.$refs.hour.childNodes[0])
|
|
107
|
+
this.$refs.hour.classList.remove(this.$style.tick)
|
|
108
|
+
this.$refs.hour.childNodes[0].innerHTML = ''
|
|
109
|
+
}, 100),
|
|
110
|
+
|
|
111
|
+
onDayEnd: debounce(function (e){
|
|
112
|
+
this.$refs.day.insertBefore(this.$refs.day.childNodes[1], this.$refs.day.childNodes[0])
|
|
113
|
+
this.$refs.day.classList.remove(this.$style.tick)
|
|
114
|
+
this.$refs.day.childNodes[0].innerHTML = ''
|
|
115
|
+
}, 100),
|
|
116
|
+
|
|
117
|
+
setInitial(){
|
|
118
|
+
if(this.$refs.day) this.$refs.day.lastElementChild.innerHTML = '1 hari'
|
|
119
|
+
if(this.$refs.hour) this.$refs.hour.lastElementChild.innerHTML = (Math.floor(this.timer / 3600) % 24).toString().padStart(2, '0')
|
|
120
|
+
if(this.$refs.minute) this.$refs.minute.lastElementChild.innerHTML = (Math.floor(this.timer / 60) % 60).toString().padStart(2, '0')
|
|
121
|
+
if(this.$refs.second) this.$refs.second.lastElementChild.innerHTML = (this.timer % 60).toString().padStart(2, '0')
|
|
122
|
+
},
|
|
123
|
+
|
|
87
124
|
start(){
|
|
88
125
|
|
|
89
126
|
this.timer = this.value
|
|
127
|
+
|
|
128
|
+
this.setInitial()
|
|
129
|
+
|
|
90
130
|
this.timeoutId = window.setInterval(() => {
|
|
91
131
|
this.timer--
|
|
132
|
+
this.tick = true
|
|
92
133
|
|
|
93
134
|
if(this.timer <= 0){
|
|
94
135
|
window.clearTimeout(this.timeoutId)
|
|
95
136
|
}
|
|
96
137
|
}, 1000)
|
|
97
|
-
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
tick(){
|
|
101
|
-
this.$refs.second.classList.add(this.$style.tick)
|
|
102
138
|
}
|
|
103
139
|
|
|
104
140
|
},
|
|
@@ -109,10 +145,32 @@ export default{
|
|
|
109
145
|
this.start()
|
|
110
146
|
},
|
|
111
147
|
|
|
148
|
+
day(to, from){
|
|
149
|
+
if(!this.tick || !this.$refs.day) return
|
|
150
|
+
this.$refs.day.firstElementChild.innerHTML = to > 0 ? to + ' hari' : ''
|
|
151
|
+
this.$refs.day.lastElementChild.innerHTML = from + ' hari'
|
|
152
|
+
this.$refs.day.classList.add(this.$style.tick)
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
hour(to, from){
|
|
156
|
+
if(!this.tick) return
|
|
157
|
+
this.$refs.hour.firstElementChild.innerHTML = to
|
|
158
|
+
this.$refs.hour.lastElementChild.innerHTML = from
|
|
159
|
+
this.$refs.hour.classList.add(this.$style.tick)
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
minute(to, from){
|
|
163
|
+
if(!this.tick) return
|
|
164
|
+
this.$refs.minute.firstElementChild.innerHTML = to
|
|
165
|
+
this.$refs.minute.lastElementChild.innerHTML = from
|
|
166
|
+
this.$refs.minute.classList.add(this.$style.tick)
|
|
167
|
+
},
|
|
168
|
+
|
|
112
169
|
second(to, from){
|
|
170
|
+
if(!this.tick) return
|
|
113
171
|
this.$refs.second.firstElementChild.innerHTML = to
|
|
114
172
|
this.$refs.second.lastElementChild.innerHTML = from
|
|
115
|
-
this.tick
|
|
173
|
+
this.$refs.second.classList.add(this.$style.tick)
|
|
116
174
|
}
|
|
117
175
|
}
|
|
118
176
|
|
|
@@ -127,13 +185,14 @@ export default{
|
|
|
127
185
|
}
|
|
128
186
|
|
|
129
187
|
.lap{
|
|
130
|
-
@apply relative overflow-hidden w-[1.
|
|
188
|
+
@apply relative overflow-hidden bg-gray-200 min-w-[1.8rem] rounded-lg text-center;
|
|
131
189
|
}
|
|
132
190
|
.lap>*{
|
|
191
|
+
@apply whitespace-nowrap font-bold;
|
|
133
192
|
}
|
|
134
193
|
.lap>*:first-child{
|
|
135
|
-
@apply absolute top-0 left-0;
|
|
136
|
-
transform: translate3d(0, -
|
|
194
|
+
@apply absolute top-0 left-0 right-0 text-center;
|
|
195
|
+
transform: translate3d(0, -1.3rem, 0);
|
|
137
196
|
}
|
|
138
197
|
.lap>*:last-child{
|
|
139
198
|
transform: translate3d(0, 0, 0);
|
|
@@ -148,7 +207,7 @@ export default{
|
|
|
148
207
|
transform: translate3d(0, 0, 0);
|
|
149
208
|
}
|
|
150
209
|
.tick>*:last-child{
|
|
151
|
-
transform: translate3d(0,
|
|
210
|
+
transform: translate3d(0, 1.3rem, 0);
|
|
152
211
|
}
|
|
153
212
|
|
|
154
213
|
</style>
|