Skip to content

Instantly share code, notes, and snippets.

@hems
Created July 12, 2014 06:26
Show Gist options
  • Save hems/b8b14f2f86b5fe35f3d1 to your computer and use it in GitHub Desktop.
Save hems/b8b14f2f86b5fe35f3d1 to your computer and use it in GitHub Desktop.
creates squares over a site and fade them when you drag your mouse over it
d =
w: $(window).width()
h: $(window).height()
sq = 100
create = (x, y) ->
dom = undefined
dom = $("<div>")
dom.css
width: sq
height: sq
position: "absolute"
top: (y * sq) + "px"
left: (x * sq) + "px"
"background-color": "black"
dom.mouseover ->
$( @ ).animate {
opacity: 0
width: 0
height: 0
}, 1000
$("body").append dom
x = 0
while x * sq < d.w
y = 0
while y * sq < d.h
create x, y
y++
x++
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment