This file contains hidden or 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
| function animate(elStyle, animationArray, time, callback) { | |
| var start = new Date(), | |
| timer = setInterval(function() { | |
| var acc = 0; | |
| for (var i = 0; i < animationArray.length; i++) { | |
| var animation = animationArray[i], | |
| progress = Math.min(1, (new Date() - start) / time), | |
| delta = animation.deltaFn(progress); | |
| elStyle[animation.style] = Math.floor(animation.from + progress * (animation.to - animation.from) * delta) + 'px'; | |
| acc += progress; |
This file contains hidden or 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
| /* | |
| * Easing Functions - inspired from http://gizma.com/easing/ | |
| * only considering the t value for the range [0, 1] => [0, 1] | |
| */ | |
| EasingFunctions = { | |
| // no easing, no acceleration | |
| linear: function (t) { return t }, | |
| // accelerating from zero velocity | |
| easeInQuad: function (t) { return t*t }, | |
| // decelerating to zero velocity |
This file contains hidden or 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
| function whichAnimationEndEvent(){ | |
| var t, | |
| el = document.createElement("fakeelement"), | |
| animations = { | |
| "animation" : "animationend", | |
| "OAnimation" : "oAnimationEnd", | |
| "MozAnimation" : "animationend", | |
| "WebkitAnimation": "webkitAnimationEnd" | |
| }; |
This file contains hidden or 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
| // tapPolyfill | |
| (function tapPolyfill() { | |
| var touch = []; | |
| function handler(e) { | |
| touch[e.type] = true; | |
| if(touch.touchstart && touch.touchend && !touch.touchmove) e.target.dispatchEvent(new CustomEvent('tap')); | |
| if(e.type == 'touchend') touch = []; | |
| } | |
| ['touchstart', 'touchend', 'touchmove'].forEach(function(event){ | |
| document.addEventListener(event, handler); |
This file contains hidden or 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
| object MessageProto { | |
| val POST = "0" | |
| val GET = "1" | |
| val message = """(\d)(\d+):(.*)""".r | |
| def main(args: Array[String]){ | |
| "023: Hello world" match { | |
| case message(msg_type, user, data) => msg_type match { | |
| case POST => println(s"User: $user\nData: $data") | |
| case GET => // Do something |
This file contains hidden or 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
| package object mail { | |
| implicit def stringToSeq(single: String): Seq[String] = Seq(single) | |
| implicit def liftToOption[T](t: T): Option[T] = Some(t) | |
| sealed abstract class MailType | |
| case object Plain extends MailType | |
| case object Rich extends MailType | |
| case object MultiPart extends MailType |
This file contains hidden or 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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
NewerOlder