-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprogram3.html
111 lines (87 loc) · 2.86 KB
/
program3.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
<html>
<head>
<style>
body{
font-family: sans-serif;
}
.container{
text-align:center;
}
button{
color: blue;
}
#grow{
font-size:5px;
}
</style>
</head>
<body>
<h1 style="text-align:center;">Text Animation</h1><br><br><br><br><br>
<div class="container">
<!--<input type="text" placeholder="Enter the number" id="to" onkeyup="generate()"/>-->
<button class="start" id="done" onkeyup="start()">Start</button>
</div><br><br><br><br><br>
<h2 id = "grow" style="text-align:center; color:red"></h2><br><br><br><br><br>
<footer>
<b style="margin-left: 42%;">Made with <span style="color:red;">♥</span> on <span class= "fa fa-coffee" style="color:red;"></span></b>
</footer>
<script>
function start() {
var var1 = setInterval(inTimer, 100);
var size = 5;
var flag = false;
var ids = document.getElementById("grow");
var btn = document.getElementById("done");
if(!flag){
btn.innerHTML = "Stop";
}else{
btn.innerHTML = "Start";
}
function inTimer() {
btn.innerHTML = "Stop";
ids.innerHTML = 'TEXT GROWING';
ids.setAttribute('style', "font-size: " + size + "px; color: red;text-align:center");
size += 5;
if(size >= 50 ){
clearInterval(var1);
var2 = setInterval(deTimer, 100);
}
}
function deTimer() {
size -= 5;
ids.innerHTML = 'TEXT SHRINKING';
ids.setAttribute('style', "font-size: " + size + "px; color: blue;text-align:center");
if(size == 5 ){
btn.innerHTML = "Start";
clearInterval(var2);
}
}
// var flag = false;
// var el = document.querySelector("h2");
// clearInterval();
//setInterval(
//function(){
//var style = window.getComputedStyle(el,null).getPropertyValue('font-size');
//var fontSize = parseFloat(style);
//if(fontSize != 50 && !flag){
// el.style.fontSize = (fontSize + 1) + 'px';
//}else{
// flag =true;
// el.innerHTML = "Text-Shrinking";
// if(fontSize!=5){
// el.style.fontSize = (fontSize - 1) + 'px';
// el.style.color = "blue";
//
// }else{
//
// falg =false;
// }
// }
// console.log(el.style.fontSize);
// },
// 100
// );
}
</script>
</body>
</html>