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

What is Framer? Join the Community
Return to index
Ryan Gambles
Posted Jul 15 - Read on Facebook

Would anybody happen to have an elegant proposal for how to determine whether I'm at the first or last page in a PageComponent? It's the end of the day and I'm done stumped.

6 Comments

Ryan Gambles

Nevermind me, I'm clearly new here. I just realized that the mypages.nextPage("right") will return me 'undefined' if I'm at the last page and mypages.nextPage("left") will return 'undefined' if I'm at the first page.

Case closed!

Benjamin Den Boer

Hey Ryan Betts - if you're also storing your page layers within an array, you could also always reference the array.length or any specific array index to check. :-)

Ryan Gambles

Benjamin Den Boer good suggestion. When layers are in a PageComponent, as it turns out they are always in an array! So you can access them via `mypages.content.subLayers`.

I was sniffing the edges because I wanted to make a circuit looping PageComponent - ie. when you get to the last page, hitting next page will take you back to the first page by transitioning to the right, instead of scanning back to the left. So, I had to use the `content.subLayers` object in order to grab the first or last page in the loop.

Might turn it into a tidy little module once I'm done the project, if I have time.

Chris Camargo

Sounds like an extension to PageComponent to me! Infinite paging would be a nice option.

Ryan Gambles

Are there best practices for extending the behaviour of Framer components? I'll happily refactor what I've implemented into a gist or whatever the community prefers.

Chris Camargo

I haven't seen much in the way of best practices for anything Framer-related, really. Two recommendations: 1) Review the Framer project on GitHub to get an idea for the way in which they write their components. 2) Check out FramerCo.de and dig into some of those Git repos. Lots of example code there.

Read the entire post on Facebook