Last active
December 26, 2015 23:18
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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