Scriptacolous: How can I know the position of a dropped element ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Scriptacolous: How can I know the position of a dropped element ?

Martin Rubi
Hello everybody.
I have a container where the user can drag & drop div elements. When the
user drops an element, I'd like to get the new element position (relative to
the container), and store it in somewhere in the model.
I tried to figure out how to get the element new position, but I couldn't.
Any clues ?


Thanks in advance
martin

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Scriptacolous: How can I know the position of a dropped element ?

Lukas Renggli
> I have a container where the user can drag & drop div elements. When the
> user drops an element,

The #onDrop: event of SUDroppable that passes you all the information you need:
the event object, the dragged element and the container element.

> I'd like to get the new element position (relative to
> the container), and store it in somewhere in the model.
> I tried to figure out how to get the element new position, but I couldn't.
> Any clues ?

Try something along the following untested code ...

html droppable
    ...
    onDrop: (html request
        callback: [ :p | p inspect ]
        value: (html element
            alias: 'arguments';
            property: 1;
            access: 'offsetTop')

... and you should get an inspector within the image giving you some
data about the dropped position.

Hope this helps,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Scriptacolous: How can I know the position of a droppedelement ?

Martin Rubi
Lukas, it's exactly what I was looking for.
Many thanks !!

best regards
martin

----- Original Message -----
From: Lukas Renggli
To: The Squeak Enterprise Aubergines Server - general discussion.
Sent: Tuesday, February 13, 2007 3:16 PM
Subject: Re: [Seaside] Scriptacolous: How can I know the position of a
droppedelement ?


> I have a container where the user can drag & drop div elements. When the
> user drops an element,

The #onDrop: event of SUDroppable that passes you all the information you
need:
the event object, the dragged element and the container element.

> I'd like to get the new element position (relative to
> the container), and store it in somewhere in the model.
> I tried to figure out how to get the element new position, but I couldn't.
> Any clues ?

Try something along the following untested code ...

html droppable
    ...
    onDrop: (html request
        callback: [ :p | p inspect ]
        value: (html element
            alias: 'arguments';
            property: 1;
            access: 'offsetTop')

... and you should get an inspector within the image giving you some
data about the dropped position.

Hope this helps,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside 

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside