Content/jqueryui/tests/unit/draggable/draggable_events.js

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/*
 * draggable_events.js
 */
(function( $ ) {

var element;

module( "draggable: events", {
	setup: function() {
		element = $("<div>").appendTo("#qunit-fixture");
	},
	teardown: function() {
		element.draggable("destroy");
	}
});

test( "callbacks occurrence count", function() {
	expect( 3 );

	var start = 0,
		stop = 0,
		dragc = 0;

	element.draggable({
		start: function() {
			start++;
		},
		drag: function() {
			dragc++;
		},
		stop: function() {
			stop++;
		}
	});

	element.simulate( "drag", {
		dx: 10,
		dy: 10
	});

	equal( start, 1, "start callback should happen exactly once" );
	equal( dragc, 3, "drag callback should happen exactly once per mousemove" );
	equal( stop, 1, "stop callback should happen exactly once" );
});

test( "stopping the start callback", function() {
	expect( 3 );

	var start = 0,
		stop = 0,
		dragc = 0;

	element.draggable({
		start: function() {
			start++;
			return false;
		},
		drag: function() {
			dragc++;
		},
后面还有 65 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。