Is there a way to use Utils.cycle() in reverse? Example: array choices = [a,b,c,d]. Pressing a keyboard key Utils.cycle() and returns choices, choices etc.
When I press backspace I want Utils.cycle to return the PREVIOUS array value (choices) not the NEXT one choices.
Any ideas how to make the Utils. cycle() bidirectional?
I guess I can do choices.reverse() and start cycling through that but looking for a better solution
You can write your own reverse cycle() :)
Radek Kyselý writing code is the last resort. Looking for lazy solutions :) hehe
Here you can find definition of default Utils.cycle()https://github.com/koenbok/Framer/blob/master/framer/Utils.coffee
The reverse version would be this. It works on its own: the problem is, you'd need to communicate "current" step between the two functions to make it work from the middle of an array :)
ok, that's cool, let me start with that. Good pointer to https://github.com/.../blob/master/framer/Utils.coffee. I should spend some more time with the source code!
Okay, finally got it :) Use any positive value (or none at all) to move forward as it's in the default Utils.cycle() or use any negative value to move backwards :)
Radek Kyselý you the man! Thanks for all the awesome examples!