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

What is Framer? Join the Community
Return to index
Christine Røde
Posted Sep 05 - Read on Facebook

What's the best way to loop through all subViews of a specific view? I tried a few for loops without success, any clue what I'm doing wrong?

(I have a folder in my PSD that contains many more folders. I need each of these to change background color on mouseover.)

8 Comments

Thomas Aylott

If you send me a zip of your framer composition I'll show you precisely what code you need

Austin Bales

Can you post your file?

Christine Røde

Thanks Thomas, messaging you now! I almost posted it, but it's for FB and this group is public. I figured it's a general question that could be helpful to others and kick off this group.

Aaron Carámbula

Quick example. just paste this gist into the framerjs.com/editor to see.
Basically focus on the for loop.
https://gist.github.com/carambula/6445764

Aaron Carámbula

Good question, too!

Thomas Aylott

parentViewA.subViews.forEach(function(childView, index){ childView.x += index * 100 })

Aaron Carámbula

woo, very fine. Updated the gist; now with more learning! https://gist.github.com/carambula/6445764

Christine Røde

Success! This snippet did the trick in my case, thanks so much Aaron and Thomas!

PSD["Options_location"].subViews.forEach(function(childView, index){
childView.on("mouseover", function(){
this.style.backgroundColor = "#eeeeee";
});
})

Read the entire post on Facebook