zoukankan      html  css  js  c++  java
  • css动画结束后 js无法修改translated值 .

    由于项目的需要,俺要做一些页面的转场动画。

    即将是移动端,肯定是首先css动画了。

    结果确发现,css动画中,如果设置animation-fill-mode: both;在动画结束后无法个性translate3d的值;

    起初,以为是项目过于复杂,代码之前造成了相互影响,可事实并非如何。

    后来,我便写了个简单demo来测试;

    css:

    @keyframes slideInRight {
        0% {
            visibility: visible;
            -webkit-transform: translate3d(100%, 0, 0);
            transform: translate3d(100%, 0, 0);
        }
    
        100% {
            visibility: visible;
            -webkit-transform: translate3d(0, 0, 0);
            transform: translate3d(0, 0, 0);
        }
    }
    
    .slideInRight {
        -webkit-animation-name: slideInRight;
        animation-name: slideInRight;
        -webkit-animation-fill-mode: both;
        animation-fill-mode: both;
    animation-duration: .35s;
    }
     

    在css动画结束后,js手动设置translate3d()竟然无效,真是很头疼,即便是在谷歌浏览器也无法设置其值。

    无奈,只能在动画结束后再先移除动画样式,但即使是这样,在部分浏览器中也会出现无法更改的情况

    1 $('.page').on('webkitAnimationEnd', function (e) {//webkit动画结束隐藏
    2         $(this).removeClass('animated slideInRight').trans3d(0);
    3     }, false);
    View Code

    真是头疼。。

    --------------------都说海水深,怎抵相思半----------------------------

  • 相关阅读:
    程序员面试金典-整数对查找
    hihocoder-1552-缺失的拼图
    论文: YOLO9000-Better,Faster,Stronger
    hihocoder-1524-逆序对
    hihocoder-1546-集合计数
    hihocoder-1543-SCI表示法
    Oracle中的定时任务JOB
    JS中时间戳处理
    Boostrap小技巧
    Struts标签 logic:iterate简单使用
  • 原文地址:https://www.cnblogs.com/huoqishi/p/kk.html
Copyright © 2011-2022 走看看