Skip to content

Commit

Permalink
More fixes for userAction
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardolundgren committed May 30, 2008
1 parent 3d16364 commit 10afdce
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions ui/tests/jquery.useraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,37 +114,42 @@ $.extend($.userAction.prototype, {
// drag helper function, thanks Richard Worth's testmouse api.
var self = this, o = this.options, center = this.findCenter(),
target = $(this.target), lastx = center.x, lasty = center.y,
fake = $(StringPool.FAKE_CURSOR_EXP);
fake = $(StringPool.FAKE_CURSOR_EXP),
speed = o.speed || StringPool.SLOW,
easing = o.easing || StringPool.SWING;

fake = fake.size() ? fake :
$(StringPool.FAKE_CURSOR_DIV)
.css({ position: StringPool.ABSOLUTE }).appendTo(document.body);

fake
.animate({ left: center.x, top: center.y }, "fast", function() {
.animate({ left: center.x, top: center.y }, speed, easing, function() {
target
.userAction(StringPool.MOUSEOVER)
.userAction(StringPool.MOUSEDOWN)
.userAction(StringPool.MOUSEMOVE);
})
.animate({ left: center.x + (dx||0), top: center.y + (dy||0) }, {
speed: "fast",
speed: speed,
easing: easing,
step: function(i, anim) {
lastx = anim.prop == StringPool.LEFT ? i : lastx;
lasty = anim.prop == StringPool.TOP ? i : lasty;
target.userAction(StringPool.MOUSEMOVE, { x: lastx, y: lasty, after: o.drag });
target.userAction(StringPool.MOUSEMOVE, { x: lastx, y: lasty, after: o.drag || o.after });
},
complete: function() {
target.userAction(StringPool.MOUSEUP).userAction(StringPool.MOUSEOUT);

// remove fake cursor
//$(this).remove();
$(this).remove();

// trigger drag queue
var queue = $.data(self.target, StringPool.DATA_QUEUE);

if (queue) queue.shift();

if (queue && queue[0]) self.drag(queue[0][0], queue[0][1]);
else $.removeData(self.target, StringPool.DATA_QUEUE);
}
});
},
Expand Down Expand Up @@ -278,7 +283,9 @@ var StringPool = {
ABSOLUTE: 'absolute',
DATA_QUEUE: 'ua-drag-queue',
TOP: 'top',
LEFT: 'left'
LEFT: 'left',
SLOW: 'slow',
SWING: 'swing'
};

})(jQuery);

0 comments on commit 10afdce

Please sign in to comment.