[Dojo-interest] dnd.constrainedMoveable question - is it possible to get the moveable item to 'follow' the mouse pointer?

Alex Bleasdale rhodlite78 at yahoo.co.uk
Wed Aug 27 18:34:23 UTC 2008


Hi,

Eugene helped me out with this one and gave me some working code :)

In case anyone reading this forum is looking for a similar solution, here's
all the code you should need to achieve this.    You'll need to create a
page with a container div called 'image-area' and which contains a smaller
div called 'viewport'...  Tested with v1.1.1:


		dojo.require("dojo.dnd.move");
			
			dojo.addOnLoad(function() {
			    var parent = dojo.byId("image-area");
			    var moveIt = new dojo.dnd.move.parentConstrainedMoveable("viewport",
{
			        within: true
			    });
				
			    dojo.connect(parent, "onmouseenter",
			    function(e) {
					var viewport = dojo.byId("viewport");
					dojo.style("viewport", {top: (e.clientY -
viewport.clientHeight/2)+'px', left: (e.clientX -
viewport.clientWidth/2)+'px'});
			        moveIt._mover = new moveIt.mover(moveIt.node, e, moveIt);
			    });
				
			    dojo.connect(parent, "onmouseleave",
				function(e) {
					if (moveIt._mover) {
					//	console.log('destroying..')
						moveIt._mover.destroy();
						delete moveIt._mover;
					}
					dojo.stopEvent(e);
			    });
			});

-- 
View this message in context: http://www.nabble.com/dnd.constrainedMoveable-question---is-it-possible-to-get-the-moveable-item-to-%27follow%27-the-mouse-pointer--tp19164533p19187038.html
Sent from the Dojo mailing list archive at Nabble.com.



More information about the Dojo-interest mailing list