author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
18 | 1 |
/*! |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2 |
* jQuery UI Effects Fold 1.13.3 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3 |
* https://jqueryui.com |
18 | 4 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5 |
* Copyright OpenJS Foundation and other contributors |
18 | 6 |
* Released under the MIT license. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
7 |
* https://jquery.org/license |
18 | 8 |
*/ |
9 |
||
10 |
//>>label: Fold Effect |
|
11 |
//>>group: Effects |
|
12 |
//>>description: Folds an element first horizontally and then vertically. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
13 |
//>>docs: https://api.jqueryui.com/fold-effect/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
14 |
//>>demos: https://jqueryui.com/effect/ |
18 | 15 |
|
16 |
( function( factory ) { |
|
19 | 17 |
"use strict"; |
18 |
||
18 | 19 |
if ( typeof define === "function" && define.amd ) { |
20 |
||
21 |
// AMD. Register as an anonymous module. |
|
22 |
define( [ |
|
23 |
"jquery", |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
24 |
"../version", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
25 |
"../effect" |
18 | 26 |
], factory ); |
27 |
} else { |
|
28 |
||
29 |
// Browser globals |
|
30 |
factory( jQuery ); |
|
31 |
} |
|
19 | 32 |
} )( function( $ ) { |
33 |
"use strict"; |
|
18 | 34 |
|
35 |
return $.effects.define( "fold", "hide", function( options, done ) { |
|
36 |
||
37 |
// Create element |
|
38 |
var element = $( this ), |
|
39 |
mode = options.mode, |
|
40 |
show = mode === "show", |
|
41 |
hide = mode === "hide", |
|
42 |
size = options.size || 15, |
|
43 |
percent = /([0-9]+)%/.exec( size ), |
|
44 |
horizFirst = !!options.horizFirst, |
|
45 |
ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ], |
|
46 |
duration = options.duration / 2, |
|
47 |
||
48 |
placeholder = $.effects.createPlaceholder( element ), |
|
49 |
||
50 |
start = element.cssClip(), |
|
51 |
animation1 = { clip: $.extend( {}, start ) }, |
|
52 |
animation2 = { clip: $.extend( {}, start ) }, |
|
53 |
||
54 |
distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ], |
|
55 |
||
56 |
queuelen = element.queue().length; |
|
57 |
||
58 |
if ( percent ) { |
|
59 |
size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ]; |
|
60 |
} |
|
61 |
animation1.clip[ ref[ 0 ] ] = size; |
|
62 |
animation2.clip[ ref[ 0 ] ] = size; |
|
63 |
animation2.clip[ ref[ 1 ] ] = 0; |
|
64 |
||
65 |
if ( show ) { |
|
66 |
element.cssClip( animation2.clip ); |
|
67 |
if ( placeholder ) { |
|
68 |
placeholder.css( $.effects.clipToBox( animation2 ) ); |
|
69 |
} |
|
70 |
||
71 |
animation2.clip = start; |
|
72 |
} |
|
73 |
||
74 |
// Animate |
|
75 |
element |
|
76 |
.queue( function( next ) { |
|
77 |
if ( placeholder ) { |
|
78 |
placeholder |
|
79 |
.animate( $.effects.clipToBox( animation1 ), duration, options.easing ) |
|
80 |
.animate( $.effects.clipToBox( animation2 ), duration, options.easing ); |
|
81 |
} |
|
82 |
||
83 |
next(); |
|
84 |
} ) |
|
85 |
.animate( animation1, duration, options.easing ) |
|
86 |
.animate( animation2, duration, options.easing ) |
|
87 |
.queue( done ); |
|
88 |
||
89 |
$.effects.unshift( element, queuelen, 4 ); |
|
90 |
} ); |
|
91 |
||
19 | 92 |
} ); |