-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdemos.html
296 lines (283 loc) · 10.1 KB
/
demos.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
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="jquery.splitlines.js"></script>
<style type="text/css">
body {
font-family: 'Lucida Sans', Helvetica, Arial, sans-serif;
margin-left:20px;
margin-top:20px;
margin-bottom: 100px;
}
h1 {
font-size: 30px;
font-weight: bold;
border-bottom: 1px solid;
}
p {
color:#666666;
}
#container>div {
margin-bottom:20px;
}
.original {
background:#eaeaea;
}
.example span, .example div {
border: 1px solid #ff0000;
}
#original-1, #example-1 {
width: 100px;
}
#original-3, #example-3 {
font-size:24px;
font-weight:bold;
line-height: 30px;
width:300px;
}
#original-4, #example-4 {
width: 100px;
line-height: 10px;
font-size:15px;
}
#example-6 {
font-style: italic;
font-size: 20px;
line-height: 24px;
width:300px;
}
#original-10, #example-10 {
max-width: 300px;
}
#original-10 p, #example-10 p {
font-family: sans-serif;
font-size: 14px;
}
#original-11, #example-11 {
max-width: 300px;
}
#original-12, #example-12 {
max-width: 300px;
}
.code {
font-family: monospace;
display:inline;
}
.animated-line-content {
opacity: 0;
animation: animtext-up .75s cubic-bezier(0.77, 0, 0.175, 1) forwards;
animation-delay: calc(.15s * var(--line-index));
}
@keyframes animtext-up {
from {
transform: translateY(100%);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
</style>
<script type="text/javascript">
// see: https://github.com/jeremyharris/split_lines/issues/3
// if this test fails, you'll see an additional line on all examples:
// `function () { return 'test'; }`
Array.prototype.test = function () {
return 'test';
};
function cycleFade() {
var div = $('#example-6');
$(div).children('div:first').animate({opacity:0}, 'slow', function() {
$(this).hide().appendTo(div);
});
// fade in the first hidden
$(div).children('div:hidden').first().show().css('opacity', 0).animate({opacity:1});
}
function cycleSlide() {
var div = $('#example-7');
var width = div.children('span:first').width();
$(div).children('span:first').animate({marginLeft: '-='+width}, 'slow', function() {
$(this).css({marginLeft: 0}).appendTo(div);
});
}
$(document).ready(function() {
$('#example-1').splitLines();
$('#example-2').splitLines({tag:'<span class="inline"><strong>', width:200});
$('#example-3').splitLines();
$('#example-4').splitLines();
$('#example-5').splitLines({width: 200});
$('#example-6').splitLines();
$('#example-7').splitLines({tag:'<span>',width: 120});
$('#example-8').splitLines({width: 10});
$('#example-9').splitLines({width: 150});
$('#example-10 p').splitLines({tag:'<span style="display:inline-block;">'});
$('#example-11').splitLines({
tag: '<div class="animated-line-content">'
});
$('#example-12').splitLines({
tag: '<div class="animated-line-wrapper"><div class="animated-line-content">'
});
$('#example-13 .example').splitLines({width: 200});
$('#example-6').css('height', 24).children().css({
position: 'absolute',
display: 'none'
});
$('#example-6').children(':first').show();
$('#example-7').css({
width: 120,
height:20,
overflow: 'hidden'
}); //.children().css({width:100});
$('#example-7').children(':first').show();
setInterval('cycleFade()', 2000);
setInterval('cycleSlide()', 2000);
});
</script>
</head>
<body>
<div id="wrapper">
<div id="container">
<h1>jQuery <span class="code">splitLines()</span> demos</h1>
<p>
<span class="code">splitLines()</span> takes a block of text and splits it up into separate lines based on the width of the box or a width passed to the function.
</p>
<blockquote>
<span class="code">splitLines()</span>
<ul>
<li><span class="code">width</span> string The width of the box. By default, it tries to use the element's width. If you don't define a width, there's no way to split it by lines!</li>
<li><span class="code">tag</span> string The tag to wrap the lines in</li>
<li><span class="code">keepHtml</span> boolean Whether or not to try and preserve the html within the element. Default is true</li>
</ul>
</blockquote>
<div>
<p>Example of text split by lines</p>
<div id="original-1" class="original">
This is an example of some long text that we want to split into lines.
</div>
<div id="example-1" class="example">
This is an example of some long text that we want to split into lines.
</div>
</div>
<div>
<p>Example of text split by lines using span tags and a defined width</p>
<div id="original-2" class="original">
This is an example of some long text that we want to split into lines. We also set it
to use a span tag and defined the width instead of using the original's width.
</div>
<div id="example-2" class="example">
This is an example of some long text that we want to split into lines. We also set it
to use a span tag and defined the width instead of using the original's width.
</div>
</div>
<div>
<p>Example of text split by lines with a larger font</p>
<div id="original-3" class="original">
This is an example of some long and large text that we want to split into lines.
</div>
<div id="example-3" class="example">
This is an example of some long and large text that we want to split into lines.
</div>
</div>
<div>
<p>Example of text split with a line height</p>
<div id="original-4" class="original">
My line height is smaller than my ascendors and descendors!
</div>
<div id="example-4" class="example">
My line height is smaller than my ascendors and descendors!
</div>
</div>
<div>
<p>Example of text that contains html</p>
<div id="original-5" class="original">
<em>Notice how the <strong>strong</strong> and emphasized tags are maintained during split.</em>
</div>
<div id="example-5" class="example">
<em>Notice how the <strong>strong</strong> and emphasized tags are maintained during split.</em>
</div>
</div>
<div>
<p>Example of text split by lines, and cycling through each other</p>
<div id="example-6">
Here's a spiffy fading example use case for <span class="code">splitLines()</span>.
</div>
</div>
<div>
<p>Another animation example</p>
<div id="example-7">
And a sliding example using <span class="code">splitLines()</span> to split into equal chunks! Isn't it neat?
</div>
</div>
<div>
<p>A test for using a width that's entirely too small</p>
<div id="example-8" class="example">
Long words will not fit into small widths!
</div>
</div>
<div>
<p>A test for preserving <code><br></code> tags.</p>
<div id="example-9" class="example">
Broken up <br/> with html line <br> breaks but still with split lines.
How about <span>words in tags<br/> with brs!</span>
</div>
</div>
<div>
<p>A test using the width of an outer container</p>
<div id="original-10" class="original">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sodales est libero, eget convallis mauris viverra eu. Fusce erat urna, blandit sed ex sit amet, sollicitudin pellentesque ex.</p>
</div>
<div id="example-10" class="example">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sodales est libero, eget convallis mauris viverra eu. Fusce erat urna, blandit sed ex sit amet, sollicitudin pellentesque ex.</p>
</div>
</div>
<div>
<p>A test using <code>--line-index</code> CSS variable to animate lines.</p>
<div id="original-11" class="original">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sodales est libero, eget convallis mauris viverra eu.
</div>
<div id="example-11" class="example">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sodales est libero, eget convallis mauris viverra eu.
</div>
</div>
<div>
<p>A test using <code>--line-index</code> CSS variable and extra tag wrappers to animate lines.</p>
<div id="original-12" class="original">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sodales est libero, eget convallis mauris viverra eu.
</div>
<div id="example-12" class="example">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sodales est libero, eget convallis mauris viverra eu.
</div>
</div>
<div>
<p>A test showing the plugin works with a selector that returns multiple nodes.</p>
<div id="original-13">
<div class="original">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sodales est libero, eget convallis mauris viverra eu.
</div>
<div class="original">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sodales est libero, eget convallis mauris viverra eu.
</div>
<div class="original">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sodales est libero, eget convallis mauris viverra eu.
</div>
</div>
<div id="example-13">
<div class="example">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sodales est libero, eget convallis mauris viverra eu.
</div>
<div class="example">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sodales est libero, eget convallis mauris viverra eu.
</div>
<div class="example">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sodales est libero, eget convallis mauris viverra eu.
</div>
</div>
</div>
</div>
</div>
</body>
</html>