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

What is Framer? Join the Community
Return to index
Lauren Bedal
Posted Mar 08 - Read on Facebook

Hello all,

I'm prototyping in Framer.js. I have a scroll component and scroll content, I'm trying to print the current x or scrollX position of the content. So if I scroll 500px to the right the code will print 500

Bg = new BackgroundLayer
backgroundColor: 'FFF'

scroll = new ScrollComponent
width: 750
height: 1334
scrollVertical: false

layerA = new Layer
width: 750 * 5
height: 1334
superLayer: scroll.content

layerA.style.background = "-webkit-linear-gradient(45deg, #2AF 0%, #F00 100%)"

# get current x value of scroll content
print layerA.scrollX

Framer Demo: http://share.framerjs.com/70pi1l6is76t/

Codepen Demo: http://codepen.io/matter/pen/78fc798001529418123b84470ea8c625?editors=0010

Thank you in advance,

2 Comments

Hannes Waller

I'm not entirely sure I get what you mean, but to print the offset you could do

scroll.on Events.Scroll, (event) ->
print event.offsetX

http://share.framerjs.com/6xbcocwddzhb/

Is that it?

Krijn Rijshouwer

Hey Lauren,

If you call the scrollX on the ScrollComponent instead of the Layer that's in the ScrollComponent it should work perfectly. I added an Event listener so it'll keep updating it when scrolling. I feel like that's what you are trying to achieve.

The solution → http://share.framerjs.com/0as2xliszr6h/

Read the entire post on Facebook