layer擴(kuò)展打開(kāi)/關(guān)閉動(dòng)畫(huà)的方法
1. 打開(kāi)窗口時(shí),支持自定義或者第三方動(dòng)畫(huà)
打開(kāi)layer.js,定位到函數(shù):Class.pt.creat ,
找到代碼:
//為兼容jQuery3.0的css動(dòng)畫(huà)影響元素尺寸計(jì)算
if (doms.anim[config.anim]) {
var animClass = 'layer-anim ' + doms.anim[config.anim];
that.layero.addClass(animClass).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
$(this).removeClass(animClass);
});
}
修改為(此處只是針對(duì)css動(dòng)畫(huà)庫(kù)animate):
//為兼容jQuery3.0的css動(dòng)畫(huà)影響元素尺寸計(jì)算
if (doms.anim[config.anim]) {
var animClass = 'layer-anim ' + doms.anim[config.anim];
that.layero.addClass(animClass).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
$(this).removeClass(animClass);
});
} else {
//支持自定義的,或者第三方彈出動(dòng)畫(huà)
var animClass = config.anim;
var animated = 'animated';
that.layero.addClass(animated);
that.layero.addClass(animClass).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
$(this).removeClass(animClass);
$(this).removeClass(animated);
});
}
至此,layer便可支持其他彈出動(dòng)畫(huà)。
2.關(guān)閉窗口時(shí),支持自定義或者第三方動(dòng)畫(huà)(layer.open時(shí)需傳入新增參數(shù):closeAnim)
打開(kāi)layer.js
定位到函數(shù):Class.pt.config
新增參數(shù):
closeAnim: 'layer-anim-close',
定位到函數(shù):Class.pt.creat
找到代碼:
//記錄關(guān)閉動(dòng)畫(huà)
if (config.isOutAnim) {
that.layero.data('isOutAnim', true);
}
修改為:
//記錄關(guān)閉動(dòng)畫(huà)
if (config.isOutAnim) {
that.layero.data('isOutAnim', true);
that.layero.data('closeAnim', config.closeAnim);
}
定位函數(shù)到:layer.close
找到代碼:
if (layero.data('isOutAnim')) {
layero.addClass('layer-anim ' + closeAnim);
}
$('#layui-layer-moves, #layui-layer-shade' + index).remove();
layer.ie == 6 && ready.reselect();
ready.rescollbar(index);
if (layero.attr('minLeft')) {
ready.minIndex--;
ready.minLeft.push(layero.attr('minLeft'));
}
if ((layer.ie && layer.ie < 10) || !layero.data('isOutAnim')) {
remove()
} else {
setTimeout(function () {
remove();
}, 200);
}
修改為:
if (layero.data('isOutAnim')) {
if (layero.data("closeAnim") === closeAnim) {
layero.addClass('layer-anim ' + closeAnim);
} else {
layero.addClass(layero.data("closeAnim") + ' animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
$('#layui-layer-moves, #layui-layer-shade' + index).remove();
remove();
});
}
}
if (layero.data("closeAnim") === closeAnim) {
$('#layui-layer-moves, #layui-layer-shade' + index).remove();
layer.ie == 6 && ready.reselect();
ready.rescollbar(index);
if (layero.attr('minLeft')) {
ready.minIndex--;
ready.minLeft.push(layero.attr('minLeft'));
}
if ((layer.ie && layer.ie < 10) || !layero.data('isOutAnim')) {
remove()
} else {
setTimeout(function () {
remove();
}, 200);
}
}
好啦,關(guān)閉也可以支持第三方動(dòng)畫(huà)啦。
以上這篇layer擴(kuò)展打開(kāi)/關(guān)閉動(dòng)畫(huà)的方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
JS window.opener返回父頁(yè)面的應(yīng)用
網(wǎng)上支付開(kāi)發(fā)分為支付平臺(tái)和客戶(hù)端兩部分。當(dāng)客戶(hù)端進(jìn)入支付平臺(tái)時(shí),需要在新窗體打開(kāi)支付平臺(tái)頁(yè)面。2009-10-10
js實(shí)現(xiàn)圖片在未加載完成前顯示加載中字樣
首先判斷瀏覽器再判斷圖片是否加載完成,如果還未加載就顯示“加載中...”,思路及代碼如下2014-09-09
Javascript中eval函數(shù)的詳細(xì)用法與說(shuō)明
Javascript中eval函數(shù)的詳細(xì)用法與說(shuō)明...2007-03-03
js中<script> 標(biāo)簽中type值及其含義
在 HTML 中的 script 標(biāo)簽中,type 屬性用于指定腳本的 MIME 類(lèi)型,也即告訴瀏覽器該如何解釋和處理腳本的內(nèi)容,這篇文章主要介紹了js中<script> 標(biāo)簽中type值及其含義,需要的朋友可以參考下2024-12-12
javascript 具名函數(shù)的四種調(diào)用方式 推薦
看四種方式執(zhí)行結(jié)果沒(méi)有區(qū)別。但如果函數(shù)有返回值的話(huà),用new方式調(diào)用時(shí)可能會(huì)讓你有些失望。2009-07-07
Js自動(dòng)截取字符串長(zhǎng)度,添加省略號(hào)(……)的實(shí)現(xiàn)方法
下面小編就為大家?guī)?lái)一篇Js自動(dòng)截取字符串長(zhǎng)度,添加省略號(hào)(……)的實(shí)現(xiàn)方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-03-03
js拆分字符串并將分割的數(shù)據(jù)放到數(shù)組中的方法
這篇文章主要介紹了js拆分字符串并將分割的數(shù)據(jù)放到數(shù)組中的方法,涉及javascript中split方法及數(shù)組的操作技巧,需要的朋友可以參考下2015-05-05

