7
|
1 /*!
|
|
2 * jQuery UI Effects Clip 1.10.4
|
|
3 * http://jqueryui.com
|
|
4 *
|
|
5 * Copyright 2014 jQuery Foundation and other contributors
|
|
6 * Released under the MIT license.
|
|
7 * http://jquery.org/license
|
|
8 *
|
|
9 * http://api.jqueryui.com/clip-effect/
|
|
10 *
|
|
11 * Depends:
|
|
12 * jquery.ui.effect.js
|
|
13 */
|
|
14 (function( $, undefined ) {
|
|
15
|
|
16 $.effects.effect.clip = function( o, done ) {
|
|
17 // Create element
|
|
18 var el = $( this ),
|
|
19 props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
|
|
20 mode = $.effects.setMode( el, o.mode || "hide" ),
|
|
21 show = mode === "show",
|
|
22 direction = o.direction || "vertical",
|
|
23 vert = direction === "vertical",
|
|
24 size = vert ? "height" : "width",
|
|
25 position = vert ? "top" : "left",
|
|
26 animation = {},
|
|
27 wrapper, animate, distance;
|
|
28
|
|
29 // Save & Show
|
|
30 $.effects.save( el, props );
|
|
31 el.show();
|
|
32
|
|
33 // Create Wrapper
|
|
34 wrapper = $.effects.createWrapper( el ).css({
|
|
35 overflow: "hidden"
|
|
36 });
|
|
37 animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
|
|
38 distance = animate[ size ]();
|
|
39
|
|
40 // Shift
|
|
41 if ( show ) {
|
|
42 animate.css( size, 0 );
|
|
43 animate.css( position, distance / 2 );
|
|
44 }
|
|
45
|
|
46 // Create Animation Object:
|
|
47 animation[ size ] = show ? distance : 0;
|
|
48 animation[ position ] = show ? 0 : distance / 2;
|
|
49
|
|
50 // Animate
|
|
51 animate.animate( animation, {
|
|
52 queue: false,
|
|
53 duration: o.duration,
|
|
54 easing: o.easing,
|
|
55 complete: function() {
|
|
56 if ( !show ) {
|
|
57 el.hide();
|
|
58 }
|
|
59 $.effects.restore( el, props );
|
|
60 $.effects.removeWrapper( el );
|
|
61 done();
|
|
62 }
|
|
63 });
|
|
64
|
|
65 };
|
|
66
|
|
67 })(jQuery);
|