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 Explode 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: Explode Effect |
|
11 |
//>>group: Effects |
|
19 | 12 |
/* eslint-disable max-len */ |
18 | 13 |
//>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness. |
19 | 14 |
/* eslint-enable max-len */ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
15 |
//>>docs: https://api.jqueryui.com/explode-effect/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
16 |
//>>demos: https://jqueryui.com/effect/ |
18 | 17 |
|
18 |
( function( factory ) { |
|
19 | 19 |
"use strict"; |
20 |
||
18 | 21 |
if ( typeof define === "function" && define.amd ) { |
22 |
||
23 |
// AMD. Register as an anonymous module. |
|
24 |
define( [ |
|
25 |
"jquery", |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
26 |
"../version", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
27 |
"../effect" |
18 | 28 |
], factory ); |
29 |
} else { |
|
30 |
||
31 |
// Browser globals |
|
32 |
factory( jQuery ); |
|
33 |
} |
|
19 | 34 |
} )( function( $ ) { |
35 |
"use strict"; |
|
18 | 36 |
|
37 |
return $.effects.define( "explode", "hide", function( options, done ) { |
|
38 |
||
39 |
var i, j, left, top, mx, my, |
|
40 |
rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3, |
|
41 |
cells = rows, |
|
42 |
element = $( this ), |
|
43 |
mode = options.mode, |
|
44 |
show = mode === "show", |
|
45 |
||
46 |
// Show and then visibility:hidden the element before calculating offset |
|
47 |
offset = element.show().css( "visibility", "hidden" ).offset(), |
|
48 |
||
49 |
// Width and height of a piece |
|
50 |
width = Math.ceil( element.outerWidth() / cells ), |
|
51 |
height = Math.ceil( element.outerHeight() / rows ), |
|
52 |
pieces = []; |
|
53 |
||
54 |
// Children animate complete: |
|
55 |
function childComplete() { |
|
56 |
pieces.push( this ); |
|
57 |
if ( pieces.length === rows * cells ) { |
|
58 |
animComplete(); |
|
59 |
} |
|
60 |
} |
|
61 |
||
62 |
// Clone the element for each row and cell. |
|
63 |
for ( i = 0; i < rows; i++ ) { // ===> |
|
64 |
top = offset.top + i * height; |
|
65 |
my = i - ( rows - 1 ) / 2; |
|
66 |
||
67 |
for ( j = 0; j < cells; j++ ) { // ||| |
|
68 |
left = offset.left + j * width; |
|
69 |
mx = j - ( cells - 1 ) / 2; |
|
70 |
||
71 |
// Create a clone of the now hidden main element that will be absolute positioned |
|
72 |
// within a wrapper div off the -left and -top equal to size of our pieces |
|
73 |
element |
|
74 |
.clone() |
|
75 |
.appendTo( "body" ) |
|
76 |
.wrap( "<div></div>" ) |
|
77 |
.css( { |
|
78 |
position: "absolute", |
|
79 |
visibility: "visible", |
|
80 |
left: -j * width, |
|
81 |
top: -i * height |
|
82 |
} ) |
|
83 |
||
84 |
// Select the wrapper - make it overflow: hidden and absolute positioned based on |
|
85 |
// where the original was located +left and +top equal to the size of pieces |
|
86 |
.parent() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
87 |
.addClass( "ui-effects-explode" ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
88 |
.css( { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
89 |
position: "absolute", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
90 |
overflow: "hidden", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
91 |
width: width, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
92 |
height: height, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
93 |
left: left + ( show ? mx * width : 0 ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
94 |
top: top + ( show ? my * height : 0 ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
95 |
opacity: show ? 0 : 1 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
96 |
} ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
97 |
.animate( { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
98 |
left: left + ( show ? 0 : mx * width ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
99 |
top: top + ( show ? 0 : my * height ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
100 |
opacity: show ? 1 : 0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
101 |
}, options.duration || 500, options.easing, childComplete ); |
18 | 102 |
} |
103 |
} |
|
104 |
||
105 |
function animComplete() { |
|
106 |
element.css( { |
|
107 |
visibility: "visible" |
|
108 |
} ); |
|
109 |
$( pieces ).remove(); |
|
110 |
done(); |
|
111 |
} |
|
112 |
} ); |
|
113 |
||
19 | 114 |
} ); |