Selaa lähdekoodia

: add timer reset on touch

master
Adrien 3 vuotta sitten
vanhempi
commit
cd8b74e1b0
3 muutettua tiedostoa jossa 32 lisäystä ja 6 poistoa
  1. +22
    -2
      src/components/Battleground/Objective.vue
  2. +9
    -3
      src/components/Battleground/Timer.vue
  3. +1
    -1
      src/main.js

+ 22
- 2
src/components/Battleground/Objective.vue Näytä tiedosto

@@ -1,12 +1,20 @@
<template> <template>


<div class="objective" >
<div
class="objective"
@click="clearObjective"
v-longclick="forceClearObjective">
<div> <div>
{{ objective.name }} {{ objective.name }}
<span v-if="objective.position"> ({{ objective.position }})</span> <span v-if="objective.position"> ({{ objective.position }})</span>
</div> </div>


<div><Timer ref="timer" :initialTime="objective.initialSpawnTime" /></div>
<div>
<Timer
ref="timer"
:initialTime="objective.initialSpawnTime"
/>
</div>
</div> </div>
</template> </template>


@@ -28,6 +36,18 @@
} }
}, },
methods: { methods: {
clearObjective: function () {
if (this.$refs.timer.currentTime === 0) {
this.resetTimer()
}
},
forceClearObjective: function () {
this.resetTimer()
},
resetTimer: function () {
this.$refs.timer.setTime(this.objective.respawnTime)
this.$refs.timer.startTimer()
}
}, },
components: { components: {
Timer Timer


+ 9
- 3
src/components/Battleground/Timer.vue Näytä tiedosto

@@ -5,16 +5,19 @@
</template> </template>


<script> <script>
'use strict'
export default { export default {
name: 'Timer', name: 'Timer',
data () { data () {
return { return {
currentTime: this.$attrs.initialTime
currentTime: this.$attrs.initialTime,
timerIntervalId: null
} }
}, },
methods: { methods: {
startTimer: function () { startTimer: function () {
this.timerIntevalId = setInterval(() => {
this.stopTimer()
this.timerIntervalId = setInterval(() => {
this.currentTime-- this.currentTime--
if (this.currentTime === 0) { if (this.currentTime === 0) {
this.stopTimer() this.stopTimer()
@@ -22,7 +25,10 @@
}, 1000) }, 1000)
}, },
stopTimer: function () { stopTimer: function () {
clearInterval(this.timerIntevalId)
clearInterval(this.timerIntervalId)
},
setTime: function (time) {
this.currentTime = time
} }
}, },
computed: { computed: {


+ 1
- 1
src/main.js Näytä tiedosto

@@ -8,7 +8,7 @@ import VueI18n from 'vue-i18n'


Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(VueI18n) Vue.use(VueI18n)
Vue.directive('longclick', longClickDirective({delay: 1000, interval: 0}))
Vue.directive('longclick', longClickDirective({delay: 750, interval: 0}))


/* eslint-disable no-new */ /* eslint-disable no-new */
new Vue({ new Vue({


Ladataan…
Peruuta
Tallenna