layer擴(kuò)展打開/關(guān)閉動(dòng)畫的方法
1. 打開窗口時(shí),支持自定義或者第三方動(dòng)畫
打開layer.js,定位到函數(shù):Class.pt.creat ,
找到代碼:
//為兼容jQuery3.0的css動(dòng)畫影響元素尺寸計(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)畫庫(kù)animate):
//為兼容jQuery3.0的css動(dòng)畫影響元素尺寸計(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)畫 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)畫。
2.關(guān)閉窗口時(shí),支持自定義或者第三方動(dòng)畫(layer.open時(shí)需傳入新增參數(shù):closeAnim)
打開layer.js
定位到函數(shù):Class.pt.config
新增參數(shù):
closeAnim: 'layer-anim-close',
定位到函數(shù):Class.pt.creat
找到代碼:
//記錄關(guān)閉動(dòng)畫 if (config.isOutAnim) { that.layero.data('isOutAnim', true); }
修改為:
//記錄關(guān)閉動(dòng)畫 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)畫啦。
以上這篇layer擴(kuò)展打開/關(guān)閉動(dòng)畫的方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
一文詳解JavaScript的事件監(jiān)聽(最新整理)
Web頁(yè)面需要經(jīng)常和用戶之間進(jìn)行交互,而交互的過(guò)程中我們可能想要捕捉這個(gè)交互的過(guò)程,比如用戶點(diǎn)擊了某個(gè)按鈕、用戶在輸入框里面輸入了某個(gè)文本、用戶鼠標(biāo)經(jīng)過(guò)了某個(gè)位置,下面介紹下JavaScript的事件監(jiān)聽,感興趣的朋友一起看看吧2024-01-01JS PHP字符串截取函數(shù)實(shí)現(xiàn)原理解析
這篇文章主要介紹了JS PHP字符串截取函數(shù)實(shí)現(xiàn)原理解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-08-08ionic js 復(fù)選框 與普通的 HTML 復(fù)選框到底有沒區(qū)別
本文通過(guò)實(shí)例給大家演示ionic js 復(fù)選框 與普通的 HTML 復(fù)選框到底有沒區(qū)別的相關(guān)知識(shí),非常不錯(cuò)具有參考借鑒價(jià)值,感興趣的朋友一起學(xué)習(xí)吧2016-06-06javascript:FF/Chrome與IE動(dòng)態(tài)加載元素的區(qū)別說(shuō)明
今天在寫一段js時(shí),發(fā)現(xiàn)IE與FF在動(dòng)態(tài)加載Html元素時(shí),有一些差別,一起過(guò)來(lái)看看下面的代碼吧2014-01-01js+css 實(shí)現(xiàn)遮罩居中彈出層(隨瀏覽器窗口滾動(dòng)條滾動(dòng))
本文為大家詳細(xì)介紹下使用js實(shí)現(xiàn)遮罩彈出層居中,且隨瀏覽器窗口滾動(dòng)條滾動(dòng),示例代碼如下,感興趣的朋友可以參考下2013-12-12