rocket

作者: 小罗程序员 | 来源:发表于2017-09-01 18:27 被阅读0次
    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;
    }
    }
    

    相关文章

      网友评论

          本文标题:rocket

          本文链接:https://www.haomeiwen.com/subject/llpkjxtx.html