分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 代码编程

关于使用css3属性:transform固定菜单位置,在滑动页面时菜单闪现抖动的问题

发布时间:2023-09-06 01:57责任编辑:胡小海关键词:暂无标签
 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,能解决该问题。

关于使用css3属性:transform固定菜单位置,在滑动页面时菜单闪现抖动的问题

原文地址:https://www.cnblogs.com/front-end-develop/p/9107549.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved