Created
December 14, 2012 17:35
-
-
Save imathis/4287186 to your computer and use it in GitHub Desktop.
Handy little jQuery extensions for working with time based class names.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(($) -> | |
# Add a class until a period of time. Fires a callback when complete | |
$.fn.addClassUntil = (className, time=400, onComplete = (->true))-> | |
el = this | |
el.addClass className | |
setTimeout (-> el.removeClass(className); onComplete()), time | |
this | |
# Add a class after a period of time. Fires a callback when complete | |
$.fn.addClassAfter = (className, time=400, onComplete = (->true))-> | |
el = this | |
setTimeout (-> el.addClass(className); onComplete()), time | |
)($) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment