forked from rstacruz/jquery.transit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.haml
More file actions
712 lines (591 loc) · 20.8 KB
/
index.haml
File metadata and controls
712 lines (591 loc) · 20.8 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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
title: Hello
--
!!! 5
%html
%head
%title jQuery Transit - CSS3 animations for jQuery
%link(rel='stylesheet' media='screen' type='text/css' href='style.css')
%meta(name='description' content='Super-smooth CSS3 transformations and transitions for jQuery.')
!= "<!--[if lt IE 9]><script src='//html5shiv.googlecode.com/svn/trunk/html5.js'></script><![endif]-->"
!= "<link href='http://fonts.googleapis.com/css?family=Marvel:400' rel='stylesheet' type='text/css'>"
!= "<link href='http://fonts.googleapis.com/css?family=Oswald:400' rel='stylesheet' type='text/css'>"
!= "<link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono' rel='stylesheet' type='text/css'>"
!= "<link href='http://fonts.googleapis.com/css?family=Signika:300' rel='stylesheet' type='text/css'>"
%script(src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js')
%script(src='jquery.transit.min.js')
%script(src='script.js')
- if ENV['ANALYTICS_ID']
:javascript
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '#{ENV["ANALYTICS_ID"]}']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
%body
%a.forkme{href: 'http://github.com/rstacruz/jquery.transit'}
%img{src: 'https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png', alt: "Fork me on Github"}
#all
%hgroup#header
%h1
jQuery Transit
%p
!= "Super-smooth CSS3 transformations and transitions for jQuery — "
%span#version<>
:javascript
$("#version").html('v'+$.transit.version);
.meta
%a.button{href: 'jquery.transit.js'}
Download
%small 17kb
%a.button{href: 'jquery.transit.min.js'}
Download (Minified)
%small 2kb gzipped
-# ============================================================================
%h2 How to use
.more.info
%p
Just include this script after jQuery. Requires jQuery 1.4+.
%br
!= "Use <em>$('...').transition</em> instead of jQuery's <em>$('...').animate</em>. It has the same syntax as <a href='http://api.jquery.com/animate/'>animate.</a>"
-# ============================================================================
%h2 Translate (move)
.info
Hover on a demo box to see it in action.
%article
.hover
.code
%h3 Translate X
%pre
!= "$('.box').transition({ <b>x: '90px'</b> });"
.field
.box{style: 'left: 10px; top: 10px;'}
%article
.hover
.code
%h3 Translate Y
%pre
!= "$('.box').transition({ <b>y: '30px'</b> });"
.field
.box{style: 'left: 10px; top: 10px;'}
%article
.hover
.code
%h3 Translate X and Y
%pre
!= "$('.box').transition({ <b>x: '200px', y: '20px'</b> });"
.field
.box{style: 'left: 10px; top: 10px;'}
-# ============================================================================
%h2 Available transformations
.info
:markdown
The following transformations are available.
Refer to the [README](https://github.com/rstacruz/jquery.transit#readme) for more information.
.info.more.transformations
:markdown
* x*(px)*
* y*(px)*
* translate*(x, y)*
* rotate*(deg)*
* rotateX*(deg)*
* rotateY*(deg)*
* rotate3d*(x, y, z, deg)*
* scale*(x, \[y\])*
* perspective*(px)*
* skewX*(deg)*
* skewY*(deg)*
-# ============================================================================
%h2 Rotation
%article
.hover
.code
%h3 Rotate
%pre
!= "$('.box').transition({ <b>rotate: '30deg'</b> });"
.field
.box{style: 'left: 180px; top: 20px;'}
-# ============================================================================
%h2 Skew
%article
.hover
.code
%h3 Skew X
%pre
!= "$('.box').transition({ <b>skewX: '30deg'</b> });"
.field
.box{style: 'left: 180px; top: 20px;'}
%article
.hover
.code
%h3 Skew Y
%pre
!= "$('.box').transition({ <b>skewY: '30deg'</b> });"
.field
.box{style: 'left: 180px; top: 20px;'}
%article
.hover
.code
%h3 Skew X and Y
%pre
!= "$('.box').transition({"
%br<>
!= " <b>skewX: '30deg',</b>"
%br<>
!= " <b>skewY: '-30deg'</b>"
%br<>
!= "});"
.field{style: 'height: 150px'}
.box{style: 'left: 180px; top: 45px;'}
-# ============================================================================
%h2 Scale
%article
.hover
.code
%h3 Scale up 120% size
%pre
!= "$('.box').transition({ <b>scale: 1.2</b> });"
.field
.box{style: 'left: 180px; top: 20px;'}
%article
.hover
.code
%h3 Scale 200% horizontally, 150% vertically
%pre
!= "$('.box').transition({ <b>scale: [2, 1.5]</b> });"
.field
.box{style: 'left: 180px; top: 25px;'}
-# ============================================================================
%h2 3D rotation
.info
:markdown
You may rotate using *rotateX* and *rotateY*. Using *perspective* is optional,
but it should always come before *rotateX/Y*.
Note that not all browsers support this yet. Try it in Firefox 10+ or Webkit browsers!
%article
.hover
.code
%h3 Rotate X
%pre
!= "$('.box').transition({"
%br<>
!= " <b>perspective: '100px',</b>"
%br<>
!= " <b>rotateX: '180deg'</b>"
%br<>
!= "});"
.field
.box{style: 'left: 180px; top: 20px;'}
%article
.hover
.code
%h3 Rotate Y
%pre
!= "$('.box').transition({"
%br<>
!= " <b>perspective: '100px',</b>"
%br<>
!= " <b>rotateY: '180deg'</b>"
%br<>
!= "});"
.field
.box{style: 'left: 180px; top: 20px;'}
%article
.hover
.code
%h3 Rotate 3D
%pre
!= "$('.box').transition({"
%br<>
!= " <b>perspective: '100px',</b>"
%br<>
!= " <b>rotate3d: '1, 1, 0, 180deg'</b>"
%br<>
!= "});"
.field
.box{style: 'left: 180px; top: 20px;'}
-# ============================================================================
%h2 Transitions for other properties
.info You can animate any available CSS property.
%article
.hover
.code
%h3 $.fn.transition for any CSS property
%pre
!= "$('.box').transition({"
%br<>
!= " <b>opacity: 0,</b>"
%br<>
!= " scale: 1.6"
%br<>
!= "});"
.field{style: 'height: 150px'}
.box{style: 'left: 180px; top: 45px;'}
%article
.hover
.code
%pre
!= "$('.box').transition({"
%br<>
!= " <b>marginLeft: '20px',</b>"
%br<>
!= " <b>height: '80px'</b>"
%br<>
!= "});"
.field{style: 'height: 130px'}
.box{style: 'left: 180px; top: 35px;'}
-# ============================================================================
%h2 Callbacks
.info
:markdown
$.fn.transition(*options, \[duration\], \[easing\], \[callback\]*);
$.fn.transition works just like $.fn.animate. You can pass a *duration*, *easing*, and *callback*.
%article
.hover
.code
%h3 Providing callbacks
%pre
!= "$('.box').transition({ x: -100 }, <b>function() {</b>"
%br<>
!= "<b> $(this).transition({ opacity: 0 });</b>"
%br<>
!= "<b>}</b>);"
.field{style: 'height: 150px'}
.box{style: 'left: 180px; top: 45px;'}
-# ============================================================================
%h2 Custom duration
%article
.hover
.code
%h3 Custom duration (jQuery style)
%pre
!= "$('.box').transition({ opacity: 0 }, <b>'slow'</b>);"
.field{style: 'height: 150px'}
.box{style: 'left: 180px; top: 45px;'}
%article
.hover
.code
%h3 Custom duration (in milliseconds)
%pre
!= "$('.box').transition({ opacity: 0 }, <b>2000</b>);"
.field{style: 'height: 150px'}
.box{style: 'left: 180px; top: 45px;'}
-# ============================================================================
%h2 Easing
.info
:markdown
Simply provide a third parameter to *$.fn.transition*.
%article.mini
.hover
.code
%h3 Linear
%pre
!= "$('.box').transition({ x: 330 }, 500, <b>'linear'</b>);"
.field{style: 'height: 53px'}
.box{style: 'left: 10px; top: 10px; height: 30px;'}
%article.mini
.hover
.code
%h3 Ease in
%pre
!= "$('.box').transition({ x: 330 }, 500, <b>'in'</b>);"
.field{style: 'height: 53px'}
.box{style: 'left: 10px; top: 10px; height: 30px;'}
%article.mini
.hover
.code
%h3 Ease
%pre
!= "$('.box').transition({ x: 330 }, 500, <b>'ease'</b>);"
.field{style: 'height: 53px'}
.box{style: 'left: 10px; top: 10px; height: 30px;'}
%article.mini
.hover
.code
%h3 Ease out
%pre
!= "$('.box').transition({ x: 330 }, 500, <b>'out'</b>);"
.field{style: 'height: 53px'}
.box{style: 'left: 10px; top: 10px; height: 30px;'}
%article.mini
.hover
.code
%h3 Ease in-out
%pre
!= "$('.box').transition({ x: 330 }, 500, <b>'in-out'</b>);"
.field{style: 'height: 53px'}
.box{style: 'left: 10px; top: 10px; height: 30px;'}
%article.mini
.hover
.code
%h3 Snap
%pre
!= "$('.box').transition({ x: 330 }, 500, <b>'snap'</b>);"
.field{style: 'height: 53px'}
.box{style: 'left: 10px; top: 10px; height: 30px;'}
%article.mini.last
.hover
.code
%h3 Custom
%pre
!= "$('.box').transition({ x: 330 }, 500, <b>'cubic-bezier(0,0.9,0.3,1)'</b>);"
.field{style: 'height: 53px'}
.box{style: 'left: 10px; top: 10px; height: 30px;'}
-# ============================================================================
%h2 Delay
%article
.hover
.code
%h3 Delay by 400ms
%pre
!= "$('.box').transition({ x: -100, <b>delay: 400</b> });"
.field{style: 'height: 150px'}
.box{style: 'left: 180px; top: 45px;'}
-# ============================================================================
%h2 Alternate easing/duration syntax
.info
:markdown
You can provide *easing* and *duration* in the options instead
Great for CoffeeScript.
%article
.hover
.code
%pre
!= "$('.box').transition({"
%br<>
!= " x: '100px',"
%br<>
!= " <b>easing: 'snap',</b>"
%br<>
!= " <b>duration: '2000ms'</b>"
%br<>
!= "});"
.field{style: 'height: 150px'}
.box{style: 'left: 180px; top: 45px;'}
-# ============================================================================
%h2 Optional units
.info
:markdown
All units (*px*, *deg*, *ms*, etc) are optional.
%article
.hover
.code
%pre
!= "$('.box').transition({"
%br<>
!= " x: <b>100</b>,"
%br<>
!= " duration: <b>2000</b>,"
%br<>
!= " rotate: <b>30</b>,"
%br<>
!= " easing: 'snap'"
%br<>
!= "});"
.field{style: 'height: 150px'}
.box{style: 'left: 180px; top: 45px;'}
-# ============================================================================
%h2 Relative units
.info
:markdown
jQuery-style relative units are supported. Start your values with either *+=* or *-=*.
%article
.hover
.code
%pre
!= "$('.box').transition({"
%br<>
!= " rotate: <b>'+=30deg'</b>,"
%br<>
!= " x: <b>'+=30'</b>"
%br<>
!= "});"
.field{style: 'height: 150px'}
.box{style: 'left: 180px; top: 45px;'}
-# ============================================================================
%h2 $.fn.css
.info
:markdown
CSS3 transform properties work with *$.fn.css* as well.
%article
.hover
.code
%pre
!= "$('.box').<b>css({</b>"
%br<>
!= " <b>x: '90px'</b>,"
%br<>
!= " <b>y: '10px'</b>,"
%br<>
!= " <b>rotate: '-10deg'</b>"
%br<>
!= "<b>}</b>)</b>;"
.field{style: 'height: 150px'}
.box{style: 'left: 10px; top: 10px'}
%article
.hover
.code
%h3 Transform (automatically adds vendor prefixes)
%pre
!= "$('.box').css({ <b>transform: 'rotate(40deg)'</b> });"
.field
.box{style: 'left: 10px; top: 10px;'}
%article
.code
%h3 Getting values
%pre
!= "$('.box').css({ rotate: '40deg' });"
%br<>
!= "alert($('.box').<b>css('rotate')</b>);"
%br<>
!= "alert($('.box').<b>css('transform')</b>);"
%button Run
.field{style: 'height: 150px'}
.box{style: 'left: 10px; top: 10px;'}
-# ============================================================================
%h2 Setting transform origins
.info
:markdown
You can provide transformation origins via *$.fn.css*. The format is
*"x y"*, where *x* and *y* are coordinates in the given element.
%article
.hover
.code
%pre
!= "$('.box').css({ <b>transformOrigin: '10px 10px'</b> });"
%br<>
!= "$('.box').transition({ rotate: 40, scale: 1.2 });"
.field
.box{style: 'left: 10px; top: 10px;'}
-# ============================================================================
%h2 Chaining / effect queue
.info
:markdown
Transit uses jQuery's [effect queue](http://api.jquery.com/queue/) by default,
exactly like *$.fn.animate*. This means that transitions will never
run in parallel.
%article
.hover
.code
%pre
!= "$('.box')."
%br<>
!= " transition({ x: '-40px' }, 250)."
%br<>
!= " transition({ x: '0px' }, 250)."
%br<>
!= " transition({ y: '-40px' }, 250)."
%br<>
!= " transition({ y: '0px' }, 250);"
.field{style: 'height: 150px; overflow: hidden;'}
.box{style: 'left: 180px; top: 45px;'}
-# ============================================================================
%h2 Transitioning from one style to another
.info
:markdown
You can chain *css* and *transition* together (*.css({ .. }).transition({ .. })*).
%article
.hover
.code
%pre
!= "$('.box')."
%br<>
!= " css({ x: '-800px' })."
%br<>
!= " transition({ x: 0 });"
.field{style: 'height: 150px; overflow: hidden;'}
.box{style: 'left: 10px; top: 10px; width: 380px; height: 130px;'}
-# ============================================================================
%h2 Browser support
.info
:markdown
- IE *10+*
- Firefox *4+*
- Safari *5+*
- Chrome *10+*
- Opera *11+*
- Mobile Safari
.more.info
:markdown
See [caniuse.com's report](http://caniuse.com/#search=transition) on CSS transitions.
To support Mobile Safari, jQuery Transit uses *translate3d* and *scale3d*.
-# ============================================================================
%h2 What about older browsers?
.more.info
:markdown
jQuery Transit degrades older browsers by simply not doing the
transformations (*rotate*, *scale*, etc) while still doing standard CSS
(*opacity*, *marginLeft*, etc) without any animation.
Delays and durations will be ignored.
-# ============================================================================
%h2 Fallback to frame-based animation
.more.info
:markdown
If you would like to fallback to classic animation when transitions
aren't supported
(usually not recommended, may be slow):
%pre
!= "<b>// Delegate .transition() calls to .animate()</b>"
%br<>
!= "<b>// if the browser can't do CSS transitions.</b>"
%br<>
= "if (!$.support.transition)"
%br<>
= " $.fn.transition = $.fn.animate;"
-# ============================================================================
%h2 Setting defaults
.more.info
%pre
!= "<b>// Transit uses the same default as $.fn.animate.</b>"
%br<>
!= "$.fx.speeds._default = 300;"
%pre
!= "<b>// Default easing is stored in $.cssEase.</b>"
%br<>
= "$.cssEase._default = 'snap';"
-# ============================================================================
%h2 Custom easing
.more.info
:markdown
Define custom easing aliases in *$.cssEase*.
%pre
!= "$.cssEase['bounce'] = 'cubic-bezier(0,1,0.5,1.3)';"
%br<>
!= "$('.box').transition({ x: 0 }, 500, <b>'bounce'</b>);"
-# ============================================================================
%h2 Source code
.info.source
%a{href: 'source.html'}
%span See the annotated source code here.
!= "→"
You may also browse the
%a{href: 'https://github.com/rstacruz/jquery.transit'}
%span GitHub repo.
!= "→"
-# ============================================================================
%h2 Upgrading info
.more.info
%p
All versions of jQuery Transit should be perfectly backward compatible with it's older versions.
If you're upgrading from an old version, see
%a{href: 'https://github.com/rstacruz/jquery.transit/blob/master/HISTORY.md'}
%span the change log
!= "→"
for info on what's changed.
-# ============================================================================
%h2 Credits
.credits
:markdown
Copyright 2011, Rico Sta. Cruz. Released under the [MIT
License](http://www.opensource.org/licenses/mit-license.php).
jQuery Transit is authored and maintained by [Rico Sta. Cruz][rsc] with help from it's
[contributors][c]. It is sponsored by my startup, [Sinefunc, Inc][sf].
* [My website](http://ricostacruz.com) (ricostacruz.com)
* [Sinefunc, Inc.](http://sinefunc.com) (sinefunc.com)
* [Github](http://github.com/rstacruz) (@rstacruz)
* [Twitter](http://twitter.com/rstacruz) (@rstacruz)
[rsc]: http://ricostacruz.com
[c]: http://github.com/rstacruz/jquery.transit/contributors
[sf]: http://sinefunc.com