Skip to content

Instantly share code, notes, and snippets.

@carambula
Last active December 26, 2015 23:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carambula/7229119 to your computer and use it in GitHub Desktop.
Save carambula/7229119 to your computer and use it in GitHub Desktop.
Framer.js function for getting a child view by partial name match. Not great if it finds more than one result.
// Simple get child function by partial name match
// useful for photoshop files with repeated layer group naming
function getChildView(view, needle){
haystack = view.subViews
for (var hay in haystack){
if (haystack[hay].name.indexOf(needle) !== -1){
return view.subViews[hay]
}
}
}
// Just pass a view with children and the string that should be in the name you want to match.
// If there are multiple matches, this will just send back one.
var myChildView = getChildView(myParentView, "button")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment