-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
156 lines (109 loc) · 3.84 KB
/
example.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TextAnimation</title>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="TextAnimation/TextAnimation.js"></script>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<!-- Aditional styles, not important -->
<style>
</style>
<!-- End of: Aditional styles -->
</head>
<body>
<div class="container">
<!-- Example 1 -->
<div class="row">
<div class="col-xs-12">
<h1>Example 1</h1>
<h4>With all available options</h4>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<h1 id="example_1"></h1>
</div>
</div>
<script>
var example_1 = new TextAnimation();
example_1.init({
// Elements ID.
id: "example_1",
// Array of messages.
messages: ["Sample text", "Another sample"],
// Dealy in [ms] between changing the message.
dealy: 600,
// First message, display only at the beginning.
start_message: "Start message",
// Dealy between single character change.
change_time_per_char: 4,
// Maximal and minimal attempts that will be taken to fit character for its place.
attemps_max: 6,
attemps_min: 3,
// Allows to skip first dealy, after .init() method is called.
force_start: false
});
</script>
<!-- End of: Example 1 -->
<!-- Example 2 -->
<div class="row">
<div class="col-xs-12">
<h1>Example 2</h1>
<h4>With default options (not recomended)</h4>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<h1 id="example_2"></h1>
</div>
</div>
<script>
var example_2 = new TextAnimation();
example_2.init({
id: "example_2",
messages: ["Message 1", "Another message"]
});
</script>
<!-- End of: Example 2 -->
<!-- Example 3 -->
<div class="row">
<div class="col-xs-12">
<h1>Example 3</h1>
<h4>More methods</h4>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<h1 id="example_3"></h1>
</div>
</div>
<script>
var example_3 = new TextAnimation();
example_3.init({
id: "example_3",
messages: ["Sample text"],
dealy: 300,
start_message: "",
change_time_per_char: 7,
attemps_max: 5,
attemps_min: 3,
force_start: true
});
// Stops playing the animation.
setTimeout(() => example_3.stop(), 4000);
// Starts playing the animation.
setTimeout(() => example_3.start(), 6000);
// Change the messages to be displayed, with possible arguments:
// 1. new_messages - array - array of messages.
// 2. force_start - bolean (default: flase) - force new messages to be displayed instantly.
setTimeout(() => example_3.set_messages(["Yes or no", "No, I am not sure"], false), 7000);
setTimeout(() => example_3.set_messages(["Dunno"], true), 10000);
// Stop playing animation and remove the element from DOM.
setTimeout(() => example_3.remove(), 19000);
</script>
<!-- End of: Example 3 -->
</div>
</body>
</html>