Skip to content

Instantly share code, notes, and snippets.

@ajmalafif
Forked from arronhunt/fetti.coffee
Created December 18, 2019 04:02
Show Gist options
  • Save ajmalafif/119356dc5f41c14b6bc736bb33f8cd7b to your computer and use it in GitHub Desktop.
Save ajmalafif/119356dc5f41c14b6bc736bb33f8cd7b to your computer and use it in GitHub Desktop.
Confetti module for FramerJS
colors = ["#f23f3f", "#ff7f3b", "#f2c83f", "#3ac95c", "#4a95ff", "#ac59ff", "#ff8aed", "#3bbdca"]
fetti_bag = []
exports.kaboom = () ->
unless fetti_bag.length > 1
for i in [0..100]
fetti = new Layer
width: 20, height: 20
scale: Utils.randomNumber(0.75, 1.25)
backgroundColor: Utils.randomChoice(colors)
x: (Screen.width/100)*i, y: Utils.randomNumber(-600, 0)
rotationX: 0
rotationY: 0
rotationZ: 0
fetti.animate
properties:
rotationY: 360
rotationX: 360
rotationZ: 360
time: Utils.randomNumber(.25, 1.25)
repeat: 9999
curve: "linear"
fetti.animate
properties:
y: screen.height + 600 + fetti.y
x: Utils.randomNumber(fetti.x-600, fetti.x+600)
time: 5
curve: "linear"
fetti.animate
properties:
opacity: 0
delay: 4.5
time: 0.5
fetti_bag.push(fetti)
Utils.delay 6, ->
for f in fetti_bag
f.destroy()
f = null
fetti_bag = []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment