-
Notifications
You must be signed in to change notification settings - Fork 4
/
Demo.html
94 lines (90 loc) · 4.22 KB
/
Demo.html
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
<!--HtmlViewer:On-->
<!DOCTYPE html>
<html>
<head>
<title>Demo for Vue-Interval directive</title>
<meta charset="utf-8" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.10/vue.js"></script>
<script src="VueInterval.js" type="text/javascript"></script>
<link href="https://fonts.googleapis.com/css?family=Convergence" rel="stylesheet">
<link rel="stylesheet" href="Demo.css" />
</head>
<body>
<a href="">Reset</a>
<h1>Vue-Interval Demo</h1>
<div id="app">
<b>Time examples</b>
<p>Current Iso-Time: <span class="c">{{dateNow | iso}}</span></p>
<p>Time since Element creation: <span class="c">{{dateNow-createTime | hhmmssFilter}}</span></p>
<p>Ticker value: <span class="c">{{ticker}} (in this case secounds)</span></p>
<p v-if="tenMinuteCnt-dateNow >0">I disapear after ten minutes: <span class="c cnt-task">{{ tenMinuteCnt - dateNow|hhmmssFilter}}</span></p>
<p>Time till New Year: <span class="c">{{nextNewYear-dateNow | inYear}}</span></p>
<br />
<b>Property updates</b>
<p>This input has no reactive model: <input type="text" id="actMe" value="CHANGE INPUT" /><br /> it could even be outside of the vue root element somewhere in the DOM.
But if you combine a vanilla Script <span class="pre">.getElementById(...).value</span> call with the <span class="pre">this.ticker</span>
into a computed property, this property will be updated at every Tick.</p>
<p>The value of the not reactive input is: <span class="yellow c">{{nonreactive}}</span></p>
<br />
<b>Simple animation examples</b><br />
<div class="box dashy">
<span>Binary changes <input type="checkbox" v-model="binaryRun" /> </span>
<div v-bind:class="{'rot':ticker%(1+binaryRun),'yellow':livingSecounds%2}" class="cent border">{{livingSecounds%2}}</div>
<div v-turning="binaryRun" class="cent round border">^</div>
<div v-turning="binaryRun" class="cent round border transi">^</div>
<div ><button v-bind:disabled="!!(ticker%(1+binaryRun))" >On</button><button v-bind:disabled="!(ticker%(1+binaryRun))">Off</button></div>
</div>
<div class="box dashy">
<span><button v-on:click="addTask">Add Task</button></span>
<transition-group name="list" tag="p" class="flex">
<div v-for="t in tasks" class="border task" v-bind:key="t" >
<button v-bind:disabled="t.iid!==null" v-on:click="startTask(t)">Go</button>
<button v-bind:disabled="t.iid===null || typeof t.iid==='string'" v-on:click="suspendTask(t)">||</button>
<button v-bind:disabled="typeof t.iid!=='string'" v-on:click="resumeTask(t)">></button>
<button v-on:click="deleteTask(t)">X</button>{{t.ttl | hhmmssFilter}}
</div>
</transition-group>
</div>
<b>Interval/Countdown with callback at the end</b><br />
<div class="box dashy">
<span>
<button v-on:click="addTask2">Add Task with End-Callback</button>
<br />
<label for="endMessage">Message</label>
<input v-on:keypress.enter="addTask2" id="endMessage" type="text" v-model="endMessage" placeholder="Endmessage"/>
<br />
<label for="t2int">Interval length</label>
<input v-on:keypress.enter="addTask2" id="t2int" type="number" v-model="t2interval" placeholder="1000" />
<br />
<label for="t2time">Livingtime (Infinity is valid)</label>
<input v-on:keypress.enter="addTask2" id="t2time" type="type" v-model="t2time" placeholder="5000" />
</span>
<div class="w100">
<p v-for="m in endMessages" v-html="m"></p>
</div>
</div>
</div>
<div id="app2">
<pre>Ticker default interval is 1000(ms)</pre>
<p><b>Ticker:</b> {{ticker}}</p>
<p><b>Ticker interval:</b> {{tickerIntervalTime}}</p>
<input type="number" ref="tickTime" placeholder="50"/> ms
<button @click="changeTicker">Adjust ticker interval</button>
<br/><br/>
</div>
<script src="Demo.js" type="text/javascript"></script>
<style>
.list-item {
display: inline-block;
margin-right: 10px;
}
.list-enter-active, .list-leave-active {
transition: all 1s;
}
.list-enter, .list-leave-to /* .list-leave-active for <2.1.8 */ {
opacity: 0;
transform: translateY(30px);
}
</style>
</body>
</html>