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

What is Framer? Join the Community
Return to index
David Kerns
Posted Aug 29 - Read on Facebook

I am relatively new to Framer and CoffeeScript – so please bear with me as I take the degree of difficulty down about 40 notches for most of you.

As a learning exercise I set about the task of creating a simple switch component. It's far from perfect in some of the finer details, but has two major problems now which I don't know how to solve.

One is that my switchBg state is not being applied if onTouchEnd (AKA mousing up) is ended outside the bounds of switchBg. Am I doing this totally wrong? Should I just be binding the state of switchBg to the state of switchHandle?

and possibly related...

Curious as to why does my .onTouchEnd needs to be wrapped in a click event on switchBg? I did this to prevent the switchHandle from twitching and fidgeting while be dragged – but I don't exactly understand *why* I had to do this.

Any input or comments on any of the above would be greatly appreciated. Also feel free to point out obvious optimizations that could be made – engineering wise this is probably far from desirable, but with some help I think I can improve on it and learn more doing so.


Joshua Tucker

Hi David, I revised your project and made comments to explain what I did. Each of my comments is preceded by "#!" so it's easy to search for.


David Kerns

Thank you. Incredibly helpful and more streamlined approach to, well – all of it. To any designer or non-developer who dabbles in code, I can highly recommend absorbing Joshua's changes.

Jorn van Dijk

Maybe this one is helpful, some small differences in the approach which could be useful to learn from:

Read the entire post on Facebook