jQuery UI Easing在jQuery插件中不起作用

时间:2015-09-03 20:04:36

标签: jquery jquery-ui jquery-plugins easing

所以,我正在创建一个插件来显示一些模态,我正在为模态打开和关闭动作创建动画,当我试图插入一些jQuery UI来简化动画时,不要这样做发生......这是我的代码,你怎么看:

$.fn.modal = function(a, c){

    var object = function(){
        if( typeof(a) === "object" ){
            return a;
        }
    }

    var settings = $.extend({
        title: "Atenção",
        action: "open",
        type: "login",
        width: "small"
    }, object() );

    var div = $('<div id="modal"><div class="modal-cont odd-correction ' + settings.width + '"><div class="head">' + settings.title + '</div><div class="body"><div class="body-cont"></div></div></div></div>'),
        divCont = div.find(".modal-cont"),
        divBody = divCont.find(".body"),
        divBodyCont = divBody.find(".body-cont"),
        divHead = divCont.find(".head");

    function returnCallBack(c){
        if( typeof(c) === "function" ){
            return c();
        }
    }

    function modalContent(){
        var data;
        $.get( "modal/" + settings.type, function(r){
            data = r;
        }).complete(function(){
            console.log(data);
            divBodyCont.html(data);
            divBodyCont.slideDown("easeInOutQuart", function(){
                $(this).animate("easeInOutQuart", {opacity: 1});
            });
        });
    }

    function openModal(c){

        $("body").prepend(div);

        div.animate("easeInOutQuart", {
            opacity: 1
        }, function(){
            divCont.animate("easeInOutQuart", {opacity: 1}, function(){
                modalContent();
            });
        });

        returnCallBack(c);
    }

    function closeModal(c){
        alert("close");
        returnCallBack(c);
    }

    this.on("click", function(e){
        e.preventDefault()
        if( typeof(a) === "function" ){
            openModal(a);
        } else{
            openModal(c);
        }
    });

    return this;

};

$("#register-trigger").modal({
    title: "Cadastre-se",
    width: "big"
});

这是一个小提琴:http://jsfiddle.net/k9s632xq/

0 个答案:

没有答案