This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Cyrus Cheng
Posted Mar 26 - Read on Facebook

Hi ,everybody, i creat a project and want to realize that reseting array position when u drag one of layer in array,the project in blow:
http://share.framerjs.com/p09kfepcbr68/
but it alway had some problem in it,who can tell me how can realize it in a right way.

8 Comments

Cyrus Cheng

someone can tell me how?

Benjamin Den Boer

Hey Cyrus Cheng - so, you want to have a few layers within an array, each with different positions snap back to their original position on DragEnd? Is that correct?

Cyrus Cheng

Benjamin Den Boer,Hi,i want to drag one of a layer in a layer array, exp..there are 1,2,3,4,5 layer, i drag 2 up to 4,then i want 3,4 layers move to 2,3 layer's position, and then i drag 5 up to 3 layer,i want to 3,4,2 layer move to3,4,5 layer's position,....but what i made in my project,it can't really make it ......my english is poor, forgive me, and do u know what i mean...?

Jonas Treub

Like how you arrange apps on the iOS springboard (homescreen)?

John Grendon Enderby

Hi Benjamin Den Boer I would like to know how to do what you suggested. I tried using jQuery but not sure I got it right.

Benjamin Den Boer

Hey John Grendon Enderby Alrighty, I created a little demo for you to illustrate: http://share.framerjs.com/cwc3q3vpclxz/

So I've created 4 layers with different x/y positions. Then, I store them in an array, which allows me to loop over all of them. Within the loop, we can make all layers draggable at once. Then, we listen to the DragStart event and store the x and y position of the layer we started dragging in a variable called "currentPoint", like this:

currentPoint = this.point

So now we have the original position of whichever layer we started dragging. Now we can listen to the DragEnd event and when we stop dragging, we animate the layer back to its original position. :-)

John Grendon Enderby

Thank you very much!

Cyrus Cheng

Jonas Treub,yes,it's like what u said...and can u tell me how?

Read the entire post on Facebook