[Javascript] Moving elements

David T. Lovering dlovering at gazos.com
Tue Apr 1 08:23:58 CST 2003


In general, when moving something it is embedded in a layer, and each layer is
moved independently.  The trick required for the earlier problem is to embed the
apparent contents of the entire window in a layer (an oxymoron of course), and
move this about inside the physical screen boundaries attached to your "real" window.

The most gruesome part (for either Netscape or IE) is to build the eventHandler
routines for the mouseDown, mouseUp, and drag events, and tie them to incremental
offset changes made to the position of the layer's reference corner.  To avoid
overflowing the eventHandler cache, you have to 'debounce' the mouse movements
by polling the mouse position every 50 to 100 msec or so (using setTimeout), but
only during the 'drag' stage of the mouse transit.

Of course, knowing the vague mechanics of something and having the working code
in your hand are two different things.

-- Dave Lovering

Andrew Gibson wrote:
> 
> >>>>>>>>>>>>>>>>>>>>>>>
> I will submit some scripts of my own, that one can find them less practical
> than entertaining, something like making page elements absolutely
> positioned, after this becoming able to move them across the page, recording
> the move, playing it back or backwards, and what is most important for me,
> very short (few lines) and very fast executionable.
> >>>>>>>>>>>>>>>>>>>>>>>
> 
> I've certainly been able to drag elements across the page witha script, at
> least in IE 5+ but I've never been able to get it slickly working in
> Netscape. I can mimic the window/outlook interface of dragging things around
> the screen, but its only effective for small images and text I've found. I
> tried doing it with a form once, but found half the form couldn't keep up
> with the drag!
> 
> Cheers
> Andrew Gibson
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript


More information about the Javascript mailing list