Sha256: 38aa054b0e1046e1c66c727feea8ce29b27c4d737f6f1e4fa729aa6d67d1afad

Contents?: true

Size: 1.61 KB

Versions: 10

Compression:

Stored size: 1.61 KB

Contents

dojo.provide("dojox.layout.DragPane");

dojo.require("dijit._Widget");

dojo.declare("dojox.layout.DragPane",
	dijit._Widget, {
	//
	// summary: Makes a pane's content dragable by/within it's surface
	//
	// description:
	//		A small widget which takes a node with overflow:auto and
	//		allows dragging to position the content. Useful with images,
	//		or for just adding "something" to a overflow-able div.
	//
	// invert: Boolean
	//		Naturally, the behavior is to invert the axis of the drag.
	//		Setting invert:false will make the pane drag in the same
	//		direction as the mouse.
	invert:true,
	
	postCreate: function(){

		this.inherited(arguments);
		this.connect(this.domNode,"onmousedown","_down");
		this.connect(this.domNode,"onmouseup","_up");
	},
	
	_down: function(e){
		// summary: mousedown handler, start the dragging
		var t = this.domNode;
		dojo.style(t,"cursor","move");
		this._x = e.pageX;
		this._y = e.pageY;
		if ((this._x < t.offsetLeft + t.clientWidth) &&
			(this._y < t.offsetTop + t.clientHeight)) {
			dojo.setSelectable(t,false);
			this._mover = this.connect(t,"onmousemove","_move");
		}
	},
	
	_up: function(e){
		// summary: mouseup handler, stop the dragging
		
		dojo.setSelectable(this.domNode,true);
		dojo.style(this.domNode,"cursor","pointer");
		this.disconnect(this._mover);
	},
	
	_move: function(e){
		// summary: mousemove listener, offset the scroll amount by the delta
		//		since our last call.
		
		var mod = this.invert ? 1 : -1;
		this.domNode.scrollTop += (this._y - e.pageY) * mod;
		this.domNode.scrollLeft += (this._x - e.pageX) * mod;
		this._x = e.pageX;
		this._y = e.pageY;
		
	}
	
});

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
dojo_src-1.5.0 dojo/dojox/layout/DragPane.js
dojo_src-1.4.3 dojo/dojox/layout/DragPane.js
dojo_src-1.4.102 dojo/dojox/layout/DragPane.js
dojo-pkg-1.132.0 data/dojo-release-1.3.2-src/dojox/layout/DragPane.js
dojo-pkg-1.120.0 data/dojo-release-1.2.0-src/dojox/layout/DragPane.js
dojo-pkg-1.121.0 data/dojo-release-1.2.1-src/dojox/layout/DragPane.js
dojo-pkg-1.122.0 data/dojo-release-1.2.2-src/dojox/layout/DragPane.js
dojo-pkg-1.123.0 data/dojo-release-1.2.3-src/dojox/layout/DragPane.js
dojo-pkg-1.130.0 data/dojo-release-1.3.0-src/dojox/layout/DragPane.js
dojo-pkg-1.131.0 data/dojo-release-1.3.1-src/dojox/layout/DragPane.js