Commit c1223a0b2ad95c388ad94570a7790074d7afbd6e

Authored by 王强
1 parent f3042649

横向滚动宽度计算,结果向上取整,取到的值一定大于等于原值,有小数就+1

src/components/horizList/horizList.vue
... ... @@ -102,16 +102,16 @@
102 102 let scrollItemBox = 0;
103 103 let clientWidth = wrapper.clientWidth;
104 104 let multiple = clientWidth / 750;
105   - let childrens = wrapper.children[0].children;
  105 + let childrens = wrapper.children[0].children;
106 106  
107 107 // 遍历子元素,获取box宽度
108 108 for (let i = 0; i < childrens.length; i++) {
109   - scrollItemBox += childrens[i].clientWidth;
110   - }
  109 + scrollItemBox += childrens[i].clientWidth;
  110 + }
111 111  
112 112 // 根据屏幕比例计算实际设置vw值
113 113 // scrollItemBox = (scrollItemBox + ((30 * multiple * (childrens.length - 1)))) / clientWidth * this.basicWidth;
114   - scrollItemBox = ((scrollItemBox + (0 * multiple)) / clientWidth * this.basicWidth);
  114 + scrollItemBox = Math.ceil(((scrollItemBox + (0 * multiple)) / clientWidth * this.basicWidth));
115 115  
116 116 // 判断scrollItemBox值,更新this.scrollItemBox宽度
117 117 if (scrollItemBox > this.basicWidth) {
... ...