-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples.html
86 lines (76 loc) · 2.43 KB
/
examples.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>TypeWriter Script Examples</title>
<link href="dist/typewriter.css" rel="stylesheet">
<style>
body {
font-size: 2em;
}
</style>
</head>
<body>
<h1></h1>
<p>As you</p>
<p></p>
<h2>Chained TypeWriters</h2>
<p id="node1"></p>
<p id="node2"></p>
<p id="node3"></p>
<script src="dist/typewriter.js"></script>
<script>
// Custom Cursor
const tw = new TypeWriter(document.querySelector('h1'), {
cursor: "\u25ae"
});
tw.write('Hi').wait().delete(2).write('This is a simple typewriter script!');
// Config Change Real-time
const tw2 = new TypeWriter(document.querySelectorAll('p')[0], {
keepBlinking: false
});
tw2.wait(2000)
.write(' can see..')
.delete(5)
.wipe()
.config({pauseMin: 50, pauseMax:50})
.write('You can change the speed.');
// Custom Class
const tw3 = new TypeWriter(document.querySelectorAll('p')[1], {
pauseMin: 50,
pauseMax: 100,
className: "myTypeWriter"
});
tw3.write('This one has a custom class name and the styles are injected, so the CSS file is not needed.');
// Chained Instances
const node1 = document.querySelector('#node1');
const node2 = document.querySelector('#node2');
const node3 = document.querySelector('#node3');
const typeWriter1 = new TypeWriter(node1, {
autoStart: false,
keepBlinking: false,
onFinish: (node, params)=>{
typeWriter2.start()
},
onStart: (node, params)=>{
console.log(node, params);
},
onTask: (task, node, params)=>{
console.log(task, node, params);
},
});
const typeWriter2 = new TypeWriter(node2, {
autoStart: false,
keepBlinking: false,
onFinish: ()=>{typeWriter3.start()}
});
const typeWriter3 = new TypeWriter(node3, {
autoStart: false,
keepBlinking: false
});
typeWriter1.write('This is the first typewriter writing..').start();
typeWriter2.write('..this is the second one..');
typeWriter3.write('..and this is the third.');
</script>
</body>
</html>