Try this:
<div id=''container''
style=''width:100px;height:200px;background-
color:#e0e0e0''></div>
<div id=''temp''></div>
<script language="javascript">
var mouseX
var mouseY
Event.observe(window,''mousemove'',function(e)
{mouseX=Event.pointerX(e);mouseY=Event.pointerY(e)},false);
new Draggable(''container'',{revert:false,onStart:function(){$
(''temp'').innerHTML="x:"+mouseX+"
y:"+mouseY}});
</script>
On Dec 18, 10:54 am, Sam Rowe
<scriptacul...-NA8LtxyqzOtZdbSWXsKqFg@public.gmane.org>
wrote:> I''m using scriptaculous 1.7.0 and I need to know the starting
pointer
> x/y in a draggable. It seems like the only thing I can get at is the
> top/left of the draggable object. I need to know the exact place the
> user clicked. Any tips appreciated.
>
> var mydrag;
> var seloff = 0;
> function init(){
> ol = $(''overlaycontainerfor-0'');
> var co = Position.cumulativeOffset(ol);
> mydrag = new
Draggable(ol,{constraint:''horizontal'',revert:true,ghosting:false,onStart:function(e){setSelDrag(e)},onEn:function(el,e){drageh(el,e)},change:function(e){locUpdate(mydrag.currentDelta(),co,e)}});}
>
> function setSelDrag(e){
> console.log(e);
> seloff = Event.pointerX(e);
> seloff = parseInt(seloff); // always returns NaN}
>
> function locUpdate(s,co,e){
> cx = parseInt(s[0]) - co[0];
> var ol = $(''overlaycontainerfor-0'');
> //var co = Position.cumulativeOffset(ol);
> var loc = $(''loc'').innerHTML=s + ''
cx:'' + cx + '' seloff:'' + seloff + ''
'' + co;
> var super = $(''o0E'');
> var mousex = Event.pointerX(e);
> super.style.left = seloff + ''px'';
> super.style.width = cx + ''px'';}
>
> function drageh(el,e){
> var element = Event.element(e);
> var mousex = Event.pointerX(e);
> var mousey = Event.pointerY(e);
> var cx = mydrag.currentDelta();
> Event.stop(e);
> //alert(element.id + ''['' + mousex +
'']['' + mousey + '']['' + cx +
'']'');
>
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---