@@ -28,21 +28,19 @@ $.effects.explode = function( o ) {
28
28
// width and height of a piece
29
29
width = Math . ceil ( el . outerWidth ( ) / cells ) ,
30
30
height = Math . ceil ( el . outerHeight ( ) / rows ) ,
31
- peices = [ ] ,
32
- i , j , pos ;
31
+ pieces = [ ] ,
32
+
33
+ // loop
34
+ i , j , left , top , mx , my ;
33
35
34
36
// clone the element for each row and cell.
35
37
for ( i = 0 ; i < rows ; i ++ ) { // ===>
36
- for ( j = 0 ; j < cells ; j ++ ) { // |||
37
- pos = {
38
- // wrapper base position in body
39
- left : offset . left + j * width ,
40
- top : offset . top + i * height ,
38
+ top = offset . top + i * height ;
39
+ my = i - ( rows - 1 ) / 2 ;
41
40
42
- // x position in matrix with 0,0 at the center
43
- rx : j - cells / 2 ,
44
- ry : i - rows / 2
45
- } ;
41
+ for ( j = 0 ; j < cells ; j ++ ) { // |||
42
+ left = offset . left + j * width ;
43
+ mx = j - ( cells - 1 ) / 2 ;
46
44
47
45
// Create a clone of the now hidden main element that will be absolute positioned
48
46
// within a wrapper div off the -left and -top equal to size of our pieces
@@ -66,21 +64,21 @@ $.effects.explode = function( o ) {
66
64
overflow : 'hidden' ,
67
65
width : width ,
68
66
height : height ,
69
- left : pos . left + ( show ? pos . rx * width : 0 ) ,
70
- top : pos . top + ( show ? pos . ry * height : 0 ) ,
67
+ left : left + ( show ? mx * width : 0 ) ,
68
+ top : top + ( show ? my * height : 0 ) ,
71
69
opacity : show ? 0 : 1
72
70
} ) . animate ( {
73
- left : pos . left + ( show ? 0 : pos . rx * width ) ,
74
- top : pos . top + ( show ? 0 : pos . ry * height ) ,
71
+ left : left + ( show ? 0 : mx * width ) ,
72
+ top : top + ( show ? 0 : my * height ) ,
75
73
opacity : show ? 1 : 0
76
74
} , o . duration || 500 , o . easing , childComplete ) ;
77
75
}
78
76
}
79
77
80
78
// children animate complete:
81
79
function childComplete ( ) {
82
- peices . push ( this ) ;
83
- if ( peices . length == rows * cells ) {
80
+ pieces . push ( this ) ;
81
+ if ( pieces . length == rows * cells ) {
84
82
animComplete ( ) ;
85
83
}
86
84
}
@@ -89,7 +87,7 @@ $.effects.explode = function( o ) {
89
87
el . css ( {
90
88
visibility : 'visible'
91
89
} ) ;
92
- $ ( peices ) . remove ( ) ;
90
+ $ ( pieces ) . remove ( ) ;
93
91
if ( ! show ) {
94
92
el . hide ( ) ;
95
93
}
0 commit comments