Skip to content

Instantly share code, notes, and snippets.

View rayros's full-sized avatar
🏝️

Paweł Łaski rayros

🏝️
View GitHub Profile
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;
/*
* 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
function whichAnimationEndEvent(){
var t,
el = document.createElement("fakeelement"),
animations = {
"animation" : "animationend",
"OAnimation" : "oAnimationEnd",
"MozAnimation" : "animationend",
"WebkitAnimation": "webkitAnimationEnd"
};
// 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);
@rayros
rayros / gist:e94beb1f0857f56b18a1
Created February 27, 2015 00:13
my concept message protocol
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
@rayros
rayros / Mail.scala
Last active August 29, 2015 14:10 — forked from dimitrisli/Mail.scala
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
@rayros
rayros / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console