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

What is Framer? Join the Community
Return to index
Sergey Voronov
Posted Mar 13 - Read on Facebook

lodash coffeescript question. I am working on rearranging slides in a grid - kinda like ios home screen moving icons. and need to shift elements in array somehow. for example [0,1,2,3,4,5,6] needs to become [0,6,1,2,3,4,5] so elements from 2nd to 6th are shifting one position forward in array. and so on - func needs to be flexible so i can shift any part of array back and forward. Can't seem to find anything in lodash

2 Comments

Steve Ruiz

I think you could do a _.pullAt with the range of items to move, and splice the return of that method back into the array at the new position. It might need a function to take into account how indexes will change after you've pulled the values, adding or removing the length of the array you've pulled in order to get the right reinsertion point.

Sergey Voronov
Read the entire post on Facebook