Resizable basic tests using userAction

This commit is contained in:
Eduardo Lundgren 2008-05-31 15:54:53 +00:00
parent 320e7a560d
commit 106d24a3a4
2 changed files with 132 additions and 22 deletions

View File

@ -151,10 +151,10 @@ $.extend($.userAction.prototype, {
if (/^sync$/i.test(o.speed)) { if (/^sync$/i.test(o.speed)) {
self.down(target); self.down(target);
for (var dt = 1; dt <= dx; dt++) { var mdx = Math.abs(dx)||0, mdy = Math.abs(dy)||0, range = Math.max(mdx, mdy);
var x = center.x + (dt <= Math.abs(dx) ? dt : 0),
y = center.y + (dt <= Math.abs(dy) ? dt : 0); for (var dt = 1; dt <= range; dt++) {
var x = center.x + (dx/mdx)*(dt <= mdx ? dt : 0), y = center.y + (dy/mdy)*(dt <= mdy ? dt : 0);
this.move(target, x, y, o.drag); this.move(target, x, y, o.drag);
} }
self.up(target); self.up(target);

View File

@ -21,38 +21,148 @@ $(document).ready(function() {
// speed = sync -> Drag syncrhonously. // speed = sync -> Drag syncrhonously.
// speed = fast|slow -> Drag asyncrhonously - animated. // speed = fast|slow -> Drag asyncrhonously - animated.
$(el).userAction("drag", { return $(el).userAction("drag", {
dx: dx, dy: dy, speed: 'sync', complete: complete dx: dx||0, dy: dy||0, speed: 'sync', complete: complete
}); });
}; };
$('#resizable1').resizable({ module("simple resize");
resize: function() {
console.log('resize')
}
});
module("Test 1"); test("ui-resizable-e resize x", function() {
test("simple resize tests", function() {
drag('.ui-resizable-se', 100, 50); var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ handles: 'all' });
expect(2);
drag(handle, 50);
equals( 149, target.width(), "compare width");
drag(handle, -50);
equals( 100, target.width(), "compare width" );
}); });
test("ui-resizable-w resize x", function() {
test("simple resize tests 2", function() {
//drag('.ui-resizable-se', 0, 1000); var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ handles: 'all' });
expect(2);
drag(handle, -50);
equals( 149, target.width(), "compare width" );
drag(handle, 50);
equals( 100, target.width(), "compare width" );
}); });
module("Test 2"); test("ui-resizable-n resize y", function() {
test("simple resize tests", function() {
//drag('.ui-resizable-se', 15, 0); var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ handles: 'all' });
expect(2);
drag(handle, 0, -50);
equals( 149, target.height(), "compare height" );
drag(handle, 0, 50);
equals( 100, target.height(), "compare height" );
}); });
test("ui-resizable-s resize y", function() {
var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ handles: 'all' });
expect(2);
drag(handle, 0, 50);
equals( 149, target.height(), "compare height" );
drag(handle, 0, -50);
equals( 100, target.height(), "compare height" );
});
test("ui-resizable-se resize xy", function() {
var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all' });
expect(4);
drag(handle, 50, 50);
equals( 149, target.width(), "compare width" );
equals( 149, target.height(), "compare height" );
drag(handle, -50, -50);
equals( 100, target.width(), "compare width" );
equals( 100, target.height(), "compare height" );
});
test("ui-resizable-sw resize xy", function() {
var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all' });
expect(4);
drag(handle, -50, -50);
equals( 149, target.width(), "compare width" );
equals( 51, target.height(), "compare height" );
drag(handle, 50, 50);
equals( 100, target.width(), "compare width" );
equals( 100, target.height(), "compare height" );
});
test("ui-resizable-ne resize xy", function() {
var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ handles: 'all' });
expect(4);
drag(handle, -50, -50);
equals( 51, target.width(), "compare width" );
equals( 149, target.height(), "compare height" );
drag(handle, 50, 50);
equals( 100, target.width(), "compare width" );
equals( 100, target.height(), "compare height" );
});
test("ui-resizable-nw resize xy", function() {
var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all' });
expect(4);
drag(handle, -50, -50);
equals( 149, target.width(), "compare width" );
equals( 149, target.height(), "compare height" );
drag(handle, 50, 50);
equals( 100, target.width(), "compare width" );
equals( 100, target.height(), "compare height" );
});
}); });