-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.coffee
More file actions
296 lines (240 loc) · 6.49 KB
/
Copy pathscript.coffee
File metadata and controls
296 lines (240 loc) · 6.49 KB
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
styles = """
/*
* "a letter form Js" v5.2.1
*/
body {
background-color: #1a1c24; color: #fff;
font-size: 1.0rem; line-height: 1.4;
-webkit-font-smoothing: subpixel-antialiased;
}
/*
* ...hello?
* 小姐姐你好哇
* 感觉碰到你好多次了
* 可以加个微信吗
* ヾ(≧▽≦*)o
*/
pre {
position: fixed;
top: 30px; bottom: 30px;
transition: left 500ms;
overflow: auto;
background-color: #313744; color: #a6c3d4;
border: 1px solid rgba(0,0,0,0.2);
padding: 24px 12px;
box-sizing: border-box;
border-radius: 3px;
box-shadow: 0px 4px 0px 2px rgba(0,0,0,0.1);
}
/*
* 先在这里丢一个小胖龙
* 眼巴巴的社恐.jpg
* (¬‿¬)
*/
pre em:not(.comment) { font-style: normal; }
.comment { color: #707e84; }
.selector { color: #c66c75; }
.selector .key { color: #c66c75; }
.key { color: #c7ccd4; }
.value { color: #d5927b; }
/*
* 左边先腾出来一下
*/
pre { left: 50%; width: 45%}
/*
* 第一次了解到代码还能这么玩
* 我感觉也确实挺有意思的
* 这才敢发出来给你
* (可能只是个烂货)
* 能搞到网页里也方便你看免得还要配置一堆环境
* 这个爱心虽然还是很丑但是html+css可能只能做到这一步了
*/
#heart, #echo {
position: fixed;
width: 300px; height: 300px;
top: calc(50% - 150px); left: calc(25% - 150px);
text-align: center;
-webkit-transform: scale(0.95);
transform: scale(0.95);
}
#heart { z-index: 8; }
#echo { z-index: 7; }
#heart::before, #heart::after, #echo::before, #echo::after {
content: '';
position: absolute;
top: 40px;
width: 150px; height: 240px;
background: #c66c75;
border-radius: 150px 150px 0 0;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
transform-origin: 0 100%;
}
#heart::before, #echo::before {
left: 150px;
}
#heart::after, #echo::after {
left: 0;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
transform-origin: 100% 100%;
}
/* 比之前那个还是好看多了吧 */
#heart::after {
box-shadow:
inset -6px -6px 0px 6px rgba(255,255,255,0.1);
}
#heart::before {
box-shadow:
inset 6px 6px 0px 6px rgba(255,255,255,0.1);
}
#heart i::before {
position: absolute;
z-index: 9;
width: 100%;
top: 35%; left: 0;
font-style: normal;
color: rgba(255,255,255,0.8);
font-weight: 100;
font-size: 30px;
text-shadow: -1px -1px 0px rgba(0,0,0,0.2);
}
@-webkit-keyframes heartbeat {
0%, 100% {
-webkit-transform: scale(0.95);
transform: scale(0.95);
}
50% {
-webkit-transform: scale(1.00);
transform: scale(1.00);
}
}
@keyframes heartbeat {
0%, 100% { transform: scale(0.95); }
50% { transform: scale(1.00); }
}
@-webkit-keyframes echo {
0% {
opacity: 0.1;
-webkit-transform: scale(1);
transform: scale(1);
}
100% {
opacity: 0;
-webkit-transform: scale(1.4);
transform: scale(1.4);
}
}
@keyframes echo {
0% {
opacity: 0.1;
transform: scale(1);
}
100% {
opacity: 0;
transform: scale(1.4);
}
}
/* 下面这一坨就可以让这个心动起来了
*/
#heart, #echo {
-webkit-animation-duration: 2000ms;
animation-duration: 2000ms;
-webkit-animation-timing-function:
cubic-bezier(0, 0, 0, 1.74);
animation-timing-function:
cubic-bezier(0, 0, 0, 1.74);
-webkit-animation-delay: 500ms;
animation-delay: 500ms;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-play-state: paused;
animation-play-state: paused;
}
#heart {
-webkit-animation-name: heartbeat;
animation-name: heartbeat;
}
#echo {
-webkit-animation-name: echo;
animation-name: echo;
}
/* 我现在能力时间有限没能给你做出更完美更好看的
* 等以后我变成程序猿了要做出更牛逼的东西来
*/
#heart, #echo {
-webkit-animation-play-state: running;
animation-play-state: running;
}
/*
* 希望你能原谅我这次生日的准备不周
* 异地确实很难在这个特殊日子我应该更用心一些
* 我会学会变得更浪漫更细心一点
* 学会对你好学会去更好的表达我的爱
* 而不是单纯的说我爱你
* (虽然今天还是一定要讲的)
* 这是陪你过的第一个生日
* 希望以后还有很多很多
* 生日快乐汪汪🎂
* 我爱你
*/
"""
openComment = false
writeStyleChar = (which) ->
# begin wrapping open comments
if which == '/' && openComment == false
openComment = true
styles = $('#style-text').html() + which
else if which == '/' && openComment == true
openComment = false
styles = $('#style-text').html().replace(/(\/[^\/]*\*)$/, '<em class="comment">$1/</em>')
# wrap style declaration
else if which == ':'
styles = $('#style-text').html().replace(/([a-zA-Z- ^\n]*)$/, '<em class="key">$1</em>:')
# wrap style value
else if which == ';'
styles = $('#style-text').html().replace(/([^:]*)$/, '<em class="value">$1</em>;')
# wrap selector
else if which == '{'
styles = $('#style-text').html().replace(/(.*)$/, '<em class="selector">$1</em>{')
else
styles = $('#style-text').html() + which
$('#style-text').html styles
$('#style-tag').append which
writeStyles = (message, index, interval) ->
if index < message.length
pre = document.getElementById 'style-text'
pre.scrollTop = pre.scrollHeight
writeStyleChar message[index++]
setTimeout (->
writeStyles message, index, if openComment then 80 else 8
), interval
# appending the tags I'll need.
$('body').append """
<style id="style-tag"></style>
<span id="echo"></span>
<span id="heart"><i></i></span>
<pre id="style-text"></pre>
"""
# faster typing in small iframe on codepen homepage
# time = if window.innerWidth <= 578 then 4 else 16
time = 80
# starting it off
writeStyles(styles, 0, time)
###
Changelog:
1.0.0: i exist!
1.0.1: heart instead of circle
1.0.2: including standard CSS3 transforms and animations
was only using `-webkit` to be less verbose (standard transforms dont work in safari)
now works in FF
1.0.3: crossbrowser echo
nested `scale()` styles (scaled in scaled) only worked in chrome
moved echo out of heart to fix
1.0.4: more efficient animations
`0%, 100% {}` instead of duplicated keyframes
1.0.5: overflwo fix
`overflow: auto` on the `pre`
###