2 * jQuery UI Effects Explode 1.11.4
5 * Copyright jQuery Foundation and other contributors
6 * Released under the MIT license.
7 * http://jquery.org/license
9 * http://api.jqueryui.com/explode-effect/
11 (function( factory
) {
12 if ( typeof define
=== "function" && define
.amd
) {
14 // AMD. Register as an anonymous module.
26 return $.effects
.effect
.explode = function( o
, done
) {
28 var rows
= o
.pieces
? Math
.round( Math
.sqrt( o
.pieces
) ) : 3,
31 mode
= $.effects
.setMode( el
, o
.mode
|| "hide" ),
32 show
= mode
=== "show",
34 // show and then visibility:hidden the element before calculating offset
35 offset
= el
.show().css( "visibility", "hidden" ).offset(),
37 // width and height of a piece
38 width
= Math
.ceil( el
.outerWidth() / cells
),
39 height
= Math
.ceil( el
.outerHeight() / rows
),
43 i
, j
, left
, top
, mx
, my
;
45 // children animate complete:
46 function childComplete() {
48 if ( pieces
.length
=== rows
* cells
) {
53 // clone the element for each row and cell.
54 for ( i
= 0; i
< rows
; i
++ ) { // ===>
55 top
= offset
.top
+ i
* height
;
56 my
= i
- ( rows
- 1 ) / 2 ;
58 for ( j
= 0; j
< cells
; j
++ ) { // |||
59 left
= offset
.left
+ j
* width
;
60 mx
= j
- ( cells
- 1 ) / 2 ;
62 // Create a clone of the now hidden main element that will be absolute positioned
63 // within a wrapper div off the -left and -top equal to size of our pieces
67 .wrap( "<div></div>" )
70 visibility
: "visible",
75 // select the wrapper - make it overflow: hidden and absolute positioned based on
76 // where the original was located +left and +top equal to the size of pieces
78 .addClass( "ui-effects-explode" )
84 left
: left
+ ( show
? mx
* width
: 0 ),
85 top
: top
+ ( show
? my
* height
: 0 ),
88 left
: left
+ ( show
? 0 : mx
* width
),
89 top
: top
+ ( show
? 0 : my
* height
),
91 }, o
.duration
|| 500, o
.easing
, childComplete
);
95 function animComplete() {