funky explode

Adding easing to ui.explode makes a strange effect

by John Schulz

HTML

<script src="http://jquery-ui.googlecode.com/svn/tags/testing/ui/jquery-ui.js"></script>
<link rel="stylesheet" href="http://jquery-ui.googlecode.com/svn/tags/testing/themes/base/jquery-ui.css">
<button>Click me</button>
<div id="a"></div>

CSS

#a {
    position: absolute;
    top: 200px;
    left: 200px;
    width: 100px;
    height: 100px;
    background: #ffadad;
    border: 2px solid #efcdad;
}

JavaScript

/*
* jQuery UI Effects Explode 1.8rc3
*
* Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* http://docs.jquery.com/UI/Effects/Explode
*
* Depends:
*    jquery.effects.core.js
*/
(function($) {
    
    $.effects.explode = function(o) {
        
        return this.queue(function() {
            
            var pieces = o.options.pieces,
                rows = pieces ? Math.round(Math.sqrt(pieces)) : 3,
                cells = pieces ? Math.round(Math.sqrt(pieces)) : 3,
                $this = $(this),
                el = $this.show().css('visibility', 'hidden'),
                offset = el.offset(),
                mode = (o.options.mode == 'toggle') ? ($this.is(':visible') ? 'hide' : 'show') : o.options.mode,
                show = (mode === 'show'),
                width = el.outerWidth(true),
                height = el.outerHeight(true),
                i = 0,
                j = 0
            ;

            o.options.mode = mode;
            
            //Substract the margins - not fixing the problem yet.
            offset.top -= parseInt(el.css("marginTop"),10) || 0;
            offset.left -= parseInt(el.css("marginLeft"),10) || 0;
            
            while(i<rows) { // =
                while(j<cells) { // ||
                    el
                        .clone()
                        .appendTo('body')
                        .wrap('<div></div>')
                        .css({
                            position: 'absolute',
                            visibility: 'visible',
                            left: -j*(width/cells),
                            top: -i*(height/rows)
                        })
                        .parent()
                        .addClass('ui-effects-explode')
                        .css({
                            position: 'absolute',
                            overflow: 'hidden',
                           ...