Skip to content

Instantly share code, notes, and snippets.

@msfeldstein
Last active May 12, 2018 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msfeldstein/bfd091c1505970f7345d to your computer and use it in GitHub Desktop.
Save msfeldstein/bfd091c1505970f7345d to your computer and use it in GitHub Desktop.
Background = new BackgroundLayer backgroundColor: "#f6f6f6"
# Placing all fields within a container
Container = new Layer backgroundColor: "transparent", width:1080, height:2000
Container.center()
#Container.style.padding = "10px 0 0 0 "
# 10 Fields
for colNumber in [0...9]
Field = new Layer
width:1080
height:240
backgroundColor: "#fff"
shadowY: 2
shadowBlur: 5
borderRadius: "6px"
y: (colNumber) * 242
Field.shadowColor = "rgba(0, 0, 0, 0.25)"
Field.superLayer = Container
Field.centerX()
# Each field gets its own Highlight and Shadow animation
Field.on Events.Click, (event, Field) ->
Field.bringToFront()
Highlight = new Layer
width:10, height:10, backgroundColor: "#eeeeee", borderRadius: "50%", opacity:0
Highlight.superLayer = Field
Highlight._prefer2d = true
# How to create a subset of list items so that when the user clicks on a lsit item it will reveal the child list
for newColNumber in [0...9]
SecondaryField = new Layer
width:1080
height:240
backgroundColor: "#000000"
shadowY: 2
shadowBlur: 5
borderRadius:"6px"
y: (colNumber) * 242
SecondaryField.superLayer = Field
SecondaryField._prefer2d = true
Field.shadowColor = "rgba(0, 0, 0, 0.25)"
# Matching the Highlight position with the click position
Highlight.x = event.clientX - Container.x - Field.x - (Highlight.width / 2)
Highlight.y = event.clientY - Container.y - Field.y - (Highlight.height / 2)
highlightAnimation = Highlight.animate
properties:
width: Field.width + 40, height: 1080, opacity: 1, x: -10 , y: Field.height/2 # Half of new height & half of Cursor height
curve: "ease", time: 0.25
# Fade & Reset Highlight
highlightAnimation.on "end" , ->
Highlight.animate
properties:
opacity: 0
curve: "ease", time: 0.1
utils.delay 0.1, ->
# Resetting the Highlight properties
Highlight.width = 160
Highlight.height = 160
# Animate Shadow
fieldAnimation = Field.animate
properties:
opacity: 1, shadowY: 10, shadowBlur: 16
curve: "ease", time: .1
# Reset Shadow
fieldAnimation.on "end" , ->
Field.animate
properties:
y: 0, height: 2000,
curve: "ease", time: 0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment