Skip to content

Instantly share code, notes, and snippets.

@kt3k
Last active August 29, 2015 14:09
Show Gist options
  • Save kt3k/da42025c801907d38ba7 to your computer and use it in GitHub Desktop.
Save kt3k/da42025c801907d38ba7 to your computer and use it in GitHub Desktop.
wait.js
var wait = function (n) {
return function () {
return new Promise(function (resolve) {
setTimeout(resolve, n);
});
};
};
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