Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Created September 21, 2015 14:04
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 chuck0523/acb9eae956d2c80fdeee to your computer and use it in GitHub Desktop.
Save chuck0523/acb9eae956d2c80fdeee to your computer and use it in GitHub Desktop.
$ ->
log = (x) ->
console.log x
img = $('#img')
w = img.prop('width')
left = img.position().left
compass = 1
num = 0
diff = 0.3
setInterval ->
num += 1
if num == 0
compass = 1
else if num == 500
compass = -1
if compass > 0
w += diff
left -= diff
else
w -= diff
left += diff
img.css({
'left' : left
'width' : w
})
, 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment