layer如何打開/關(guān)閉動(dòng)畫

小編給大家分享一下layer如何打開/關(guān)閉動(dòng)畫,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

創(chuàng)新互聯(lián)專注于興城網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供興城營(yíng)銷型網(wǎng)站建設(shè),興城網(wǎng)站制作、興城網(wǎng)頁(yè)設(shè)計(jì)、興城網(wǎng)站官網(wǎng)定制、重慶小程序開發(fā)公司服務(wù),打造興城網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供興城網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。

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);
      }
    }

以上是“l(fā)ayer如何打開/關(guān)閉動(dòng)畫”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

本文題目:layer如何打開/關(guān)閉動(dòng)畫
分享地址:http://muchs.cn/article20/pgosjo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、網(wǎng)站建設(shè)網(wǎng)站收錄定制網(wǎng)站、關(guān)鍵詞優(yōu)化、商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化