Sha256: 26467f3d6c51e5def6f9861227e2204a6048da4bfd428db2bb446ebe64a59412

Contents?: true

Size: 1.87 KB

Versions: 11

Compression:

Stored size: 1.87 KB

Contents

module("Callback Properties");

$.each(["init","start","","end"],function( i, type ){
	
	test('"drag'+ type +'" callback',function(){
						
		expect( 13 );
		
		// create the markup for the test
		var $div = $('<div />')
			.appendTo( document.body ),
		// starting position
		sx = Math.round( Math.random() * 90 ) + 5,
		sy = Math.round( Math.random() * 90 ) + 5,
		// mouse offset position
		mx = Math.round( Math.random() * 90 ) + 5,
		my = Math.round( Math.random() * 90 ) + 5,
		// distance dragged
		dx = Math.round( Math.random() * 90 ) + 5,
		dy = Math.round( Math.random() * 90 ) + 5;
	
		$div
			.drag( type, function( event, dd ){
				
				ok( dd.target == $div[0], "target: [drag target]" );
				ok( dd.drag == $div[0], "drag: [drag target]" );
				ok( dd.proxy == $div[0], "proxy: [drag target]" );
				
				equals( dd.startX, sx + mx, "startX" );
				equals( dd.startY, sy + my, "startY" );
				
				equals( dd.deltaX, i ? dx : 0, "deltaX" );
				equals( dd.deltaY, i ? dy : 0, "deltaY" );
				
				equals( dd.originalX, sx, "originalX" );
				equals( dd.originalY, sy, "originalY" );
				
				equals( dd.offsetX, i ? sx + dx : sx, "offsetX" );
				equals( dd.offsetY, i ? sy + dy : sy, "offsetY" );
				
				ok( dd.drop.constructor == Array && !dd.drop.length, "drop: []" );
				ok( dd.available.constructor == Array && !dd.available.length, "available: []" );
				
			})
			.css({
				position: 'absolute',
				top: sy,
				left: sx,
				height: 100,
				width: 100
			})
			// simulate a drag
			.fire("mousedown",{ 
				pageX: sx + mx, 
				pageY: sy + my
			})
			.fire("mousemove",{ 
				pageX: sx + mx + dx, 
				pageY: sy + my + dy
			})
			.fire("mouseup",{ 
				pageX: sx + mx + dx, 
				pageY: sy + my + dy 
			})
			.fire("click",{ 
				pageX: sx + mx + dx, 
				pageY: sy + my + dy 
			});
		$div.remove();
	});
});

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bonethug-0.0.17 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/event.drag/test/properties.js
bonethug-0.0.16 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/event.drag/test/properties.js
bonethug-0.0.15 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/event.drag/test/properties.js
bonethug-0.0.14 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/event.drag/test/properties.js
bonethug-0.0.13 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/event.drag/test/properties.js
bonethug-0.0.12 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/event.drag/test/properties.js
bonethug-0.0.11 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/event.drag/test/properties.js
bonethug-0.0.10 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/event.drag/test/properties.js
bonethug-0.0.7 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/event.drag/test/properties.js
bonethug-0.0.6 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/event.drag/test/properties.js
bonethug-0.0.5 skel/project_types/silverstripe3/public/abc/javascript/library/jQuery/event.drag/test/properties.js