export default {
rocketcss(rocket, target, theclass,timeout,callback) {
var cloned = $(rocket).clone();
var offset_target = $(target).offset();
var offset_rocket = $(rocket).offset();
cloned.insertAfter(rocket);
$(rocket).css({ "opacity": "0" });
cloned.css({ "position": "fixed", "z-index": "999999", "top": offset_rocket.top + "px", "left": offset_rocket.left + "px", "right": "auto", "bottom": "auto", "margin": "auto", "padding": "auto", "opacity": "1" });
var p = new Promise(function(resolve, reject){
//做一些异步操作
cloned.addClass('mover ' + (theclass || 'rocketPulseHole') );
cloned.animate({ 'top': offset_target.top + 'px', 'left': offset_target.left + 'px'}, timeout,function(){
resolve();
});
});
p.then((resolve)=>{
cloned.fadeOut(300,function(){
cloned.remove()
});
})
.then(()=>{
callback()
})
return cloned;
}
}
网友评论