Last active
August 29, 2015 14:09
-
-
Save kt3k/da42025c801907d38ba7 to your computer and use it in GitHub Desktop.
wait.js
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
var wait = function (n) { | |
return function () { | |
return new Promise(function (resolve) { | |
setTimeout(resolve, n); | |
}); | |
}; | |
}; |
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
var Logo = (function () { | |
'use strict'; | |
var Logo = function (path) { | |
this.img = $('<img />').attr('src', path) | |
this.reset(); | |
}; | |
Logo.prototype.reset = function (dom) { | |
this.img | |
.addClass('splash-logo') | |
.css('opacity', 0) | |
.css('transform', 'translate(0, -10px)'); | |
}; | |
Logo.prototype.appendTo = function (dom) { | |
this.img.appendTo(dom); | |
return this; | |
}; | |
Logo.prototype.animation = function () { | |
var logo = this.img; | |
return wait(100)().then(function () { | |
logo.css('opacity', 1); | |
logo.css('transform', 'translate(0, 0)'); | |
}).then(wait(1000)).then(function () { | |
logo.css('opacity', 0); | |
logo.css('transform', 'translate(0, 10px)'); | |
}).then(wait(500)).then(function () { | |
logo.remove(); | |
}); | |
}; | |
return Logo; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment