zoukankan      html  css  js  c++  java
  • 关于使用css3属性:transform固定菜单位置,在滑动页面时菜单闪现抖动的问题

     1 myScroll = new IScroll('#h-s-wrapper', {
     2         scrollX: true,
     3         scrollY: true,
     4         probeType: 3,
     5         mouseWheel: true,
     6         bounce: false,        //锁定边界,不允许拖拽
     7         //click: true
     8         //preventDefault: false,
     9         preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT|A)$/ }
    10     });
    11     myScroll.on('scroll', updatePosition);
    12     myScroll.on('scrollEnd', loadNewData);
     1 function updatePosition() {
     2     /// <summary>设置锁定表头、列</summary>
     3     var iTop = this.y;
     4     var iLeft = this.x;
     5     //上下滑动,当iTop为负值时,表明容器的顶边在Y轴上0位置上边
     6     if (iTop < 0) {
     7         //$('#h-s-content table thead tr').css('transform', 'translate(0px, ' + Math.abs(iTop) + 'px)');//使用translate,在上下滑动页面时,固定的菜单会出现抖动现象
     8         $('#h-s-content table thead tr').css('transform', 'translate3d(0px, ' + Math.abs(iTop) + 'px,0px)');
     9 
    10     } else {
    11         //此处设置为0,因为存在惯性滑动,向下滑动时会导致容器的坐标会越过Y轴的0坐标,变成正值,会造成设置thead表头的坐标向下偏移
    12         $('#h-s-content table thead tr').css('transform', 'translate3d(0px, 0px, 0px)');
    13     }
    14     //左右滑动;当iLeft为负值时,表明容器的左侧边在X轴上0位置的左侧
    15     if (iLeft < 0) {
    16         $('#h-s-content table tr th:first-child, td:first-child').css('transform', 'translate3d(' + Math.abs(iLeft) + 'px, 0px,0px)');
    17     } else {
    18         $('#h-s-content table tr th:first-child, td:first-child').css('transform', 'translate3d(0px, 0px, 0px)');
    19     }
    20 }

    解决办法:使用transform方式固定菜单、表头,在上下滚动页面时菜单会出现抖动现象,将translate改成translate3d,能解决该问题。

  • 相关阅读:
    我的Firefox
    九成偏股基金净值增长弱于大盘 仅18只跑赢指数
    大事记:
    Symantec AntiVirus企业版(接受管理)客户机端卸载方法
    CDP
    两行代码解决iOS上拉下拉时,底部栏顶部栏跟随手势滚动
    8Windows概要
    4断点和单步执行
    win7下windbg本机内核调试
    windbg技巧看和改标志位创建进程时断下
  • 原文地址:https://www.cnblogs.com/front-end-develop/p/9107549.html
Copyright © 2011-2022 走看看