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

What is Framer? Join the Community
Return to index
Chris Camargo
Posted Jul 23 - Read on Facebook

Can someone explain this? The code shown will print negative y values when sliding my scroller upward (expected). But if I say "print @scrollY", it always prints 0 (unexpected). scroller is just a standard ScrollComponent.


Koen Bok

Woops perfect storm.

- The @ here is the content layer
- @content.y is always the same as [email protected]
- The @scrollY in this case is the "old style overflow: scroll" scrollY that is still on every layer for compat reasons.

You will get what you expect if you do "print @superLayer.scrollY"

Maybe a solution is to scope Events.Move to the ScrollComponent instead of the ScrollComponent.content, but that is not consistent with everywhere else. I'll have to think about this a bit more.

Chris Camargo

I see I tripped on a tough one. Glad I'm not serving up the easy ones. :)

Koen Bok

There is some beauty in this complexity. Hmmm programming.

JL Flores Mena

I think this has to do with how Javascript handles 'this' (or '@'). A good way to think of it, is that 'this' refers to the call-site, not to its apparent scope (ie. inside a function).
I don't know anything (lol), but last week I started to read this awesome book (this is the chapter that talks about 'this')
I hate the title (You don't know JS), it makes it really difficult to recommend this book to someone without feeling like you're being a smartass.

Chris Camargo

Excellent reading, JL! I'm going to be spending some time with this series.

Jordan Robert Dobson

Coffeescript bends these rules slightly however. Thanks for sharing that book!

Jordan Robert Dobson

Koen Bok - in this instance might it make sense to just map the scrollY to the superLayer value?

That kinda makes sense since you'd never really use scrollY on the content in a scrollComponent scenario.

Benjamin Den Boer

Thanks for sharing JL Flores Mena - that looks like a great read. :-)

Read the entire post on Facebook