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

Eugene Lazutkin eugene.lazutkin at gmail.com
Tue Aug 26 19:35:30 UTC 2008


I answered your question in the forum, where you posted it too.

Thanks,

Eugene

Alex Bleasdale wrote:
> Hi,
> 
> Hoping this is the right place to post for this question.
> 
> I'm hoping someone can help.  I have been using constrainedMoveable and have
> a page with a container div and a smaller div inside.  At the moment, the
> user is able to drag the smaller div around inside the constraints of the
> parent container and this works very well.   
> 
> However, I'd been trying to get the smaller div to track with the pointer as
> soon as the user moves the mouse into the containing div - in other words:
> as soon as they move into the containing div, I'd like the smaller div to
> follow the pointer around.  
> 
> I can see how this might be achieved just with javascript, but I'm sure
> there's a good way to do this whilst using
> dojo.dnd.move.constrainedMoveable, so I was hoping maybe someone on this
> forum would be kind enough to assist?  
> 
> Attached is the javascript for the constrained moveable item and in the html
> body, I've got two divs: the container div is called image-area and the
> smaller (moveable) div is called viewport (and is inside the container div):    
> 
> 
> dojo.require("dojo.dnd.Moveable");
> dojo.require("dojo.dnd.move");
> 
> dojo.addOnLoad(function() {
>     var constraintContainer = function() {
>         var marginBox = dojo.marginBox("image-area");
>         boundary = {};
>         // Top, Left, Width, Height
>         boundary["t"] = 0;
>         boundary["l"] = 0;
>         boundary["w"] = marginBox.l + marginBox.w;
>         boundary["h"] = marginBox.h + marginBox.t;
>         return boundary;
>     }
>     var moveIt = new dojo.dnd.move.constrainedMoveable("viewport", {
>         constraints: constraintContainer,
>         within: true
>     });
> });
> 
> 
> Can anyone offer any advice regarding this?  Thanks very much in advance.



More information about the Dojo-interest mailing list