2 * jQuery UI Effects Explode 1.9.2
5 * Copyright 2012 jQuery Foundation and other contributors
6 * Released under the MIT license.
7 * http://jquery.org/license
9 * http://api.jqueryui.com/explode-effect/
14 (function( $, undefined ) {
16 $.effects
.effect
.explode = function( o
, done
) {
18 var rows
= o
.pieces
? Math
.round( Math
.sqrt( o
.pieces
) ) : 3,
21 mode
= $.effects
.setMode( el
, o
.mode
|| "hide" ),
22 show
= mode
=== "show",
24 // show and then visibility:hidden the element before calculating offset
25 offset
= el
.show().css( "visibility", "hidden" ).offset(),
27 // width and height of a piece
28 width
= Math
.ceil( el
.outerWidth() / cells
),
29 height
= Math
.ceil( el
.outerHeight() / rows
),
33 i
, j
, left
, top
, mx
, my
;
35 // children animate complete:
36 function childComplete() {
38 if ( pieces
.length
=== rows
* cells
) {
43 // clone the element for each row and cell.
44 for( i
= 0; i
< rows
; i
++ ) { // ===>
45 top
= offset
.top
+ i
* height
;
46 my
= i
- ( rows
- 1 ) / 2 ;
48 for( j
= 0; j
< cells
; j
++ ) { // |||
49 left
= offset
.left
+ j
* width
;
50 mx
= j
- ( cells
- 1 ) / 2 ;
52 // Create a clone of the now hidden main element that will be absolute positioned
53 // within a wrapper div off the -left and -top equal to size of our pieces
57 .wrap( "<div></div>" )
60 visibility
: "visible",
65 // select the wrapper - make it overflow: hidden and absolute positioned based on
66 // where the original was located +left and +top equal to the size of pieces
68 .addClass( "ui-effects-explode" )
74 left
: left
+ ( show
? mx
* width
: 0 ),
75 top
: top
+ ( show
? my
* height
: 0 ),
78 left
: left
+ ( show
? 0 : mx
* width
),
79 top
: top
+ ( show
? 0 : my
* height
),
81 }, o
.duration
|| 500, o
.easing
, childComplete
);
85 function animComplete() {