Created
March 17, 2011 07:20
-
-
Save tlync/873963 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dojo.declare('dojo.dnd.move.parentConstrainedGridMoveable', dojo.dnd.move.parentConstrainedMoveable, { | |
gridSize: 10, | |
/* | |
* @param {HTMLElement} node | |
* @param {int} params.gridSize | |
*/ | |
constructor: function(node, params){ | |
if(!params) params = {}; | |
this.gridSize = params && params.gridSize; | |
}, | |
onMove: function(mover, leftTop){ | |
var c = this.constraintBox; | |
var s = mover.node.style; | |
var gridSize = this.gridSize; | |
var left = (leftTop.l < c.l ? c.l : c.r < leftTop.l ? c.r : leftTop.l); | |
var top = (leftTop.t < c.t ? c.t : c.b < leftTop.t ? c.b : leftTop.t); | |
s.left = left - left % gridSize + 'px'; | |
s.top = top - top % gridSize + 'px'; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment