Skip to content

Instantly share code, notes, and snippets.

@charliecm
Last active October 2, 2015 21:49
Show Gist options
  • Save charliecm/db2981d87d015cb45fcb to your computer and use it in GitHub Desktop.
Save charliecm/db2981d87d015cb45fcb to your computer and use it in GitHub Desktop.
(Framer module) Extends the Layer class with a new function that returns the first nested sublayer from the provided path of names.
# Extends the Layer class with a new function that returns the first nested
# sublayer from the provided path of names.
# e.g., innerCircle = screenLayer.sublayerByPath('Box/Inner_Box/Inner_Circle')
Layer.prototype.subLayerByPath = (path = '', delimeter = '/') ->
names = path.split(delimeter)
layers = this.subLayersByName(names.shift() || '')
if (layers.length && names.length)
path = names.join(delimeter)
return layers[0].subLayerByPath(path)
else
return layers[0] || false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment