Explorar o código

优化滚动空白

wenjie hai 2 semanas
pai
achega
7b660e652f

+ 9 - 4
pages/category/category.js

@@ -81,10 +81,15 @@ Page({
         index:this.data.subIndex+1
       }
     }}
-    this.onleftMenuTab(data)
-    // this.setData({
-    //   topHeight:0
-    // })
+    
+    this.setData({
+      topHeight:15
+    },() => {
+      // 3. 延迟恢复样式(避免视觉闪烁)
+      setTimeout(() => {
+        this.onleftMenuTab(data)
+      }, 0);
+    })
   },
   handleSale(){
     this.setData({

+ 1 - 2
pages/category/category.wxml

@@ -88,7 +88,6 @@
       <image class="banner" src="../../images/imgs/banner.png" mode="" />
       <!-- <text wx:if="{{subCategoryList.length>0}}" class="sub-title" >{{subCategoryList[subIndex].categoryName}}</text> -->
     <view class="loading" wx:if="{{showLoading}}">
-      <!-- <van-icon class="icon" color="#006CE8" size="50rpx" name="replay" /> -->
       <image class="icon" src="../../images/imgs/loading-icon.png" mode=""/>
     </view>
       <view class="right-top-box">
@@ -108,7 +107,7 @@
           </view>
         </view>
       </view>
-      <scroll-view class="right-box"  scroll-y="true" 	enable-passive scroll-into-view="{{rightView}}"	upper-threshold="10" 	lower-threshold="10"  scroll-top="{{topHeight}}" bindscroll="scroll"bindscrolltoupper="scrollTop" bindscrolltolower="scrollBottom">
+      <scroll-view class="right-box"  scroll-y="true" 	enable-passive 	upper-threshold="10" 	lower-threshold="10"  scroll-top="{{topHeight}}" bindscroll="scroll" bindscrolltoupper="scrollTop" bindscrolltolower="scrollBottom">
         <view class="product-item" id="{{'test'+index}}" wx:for="{{productList}}">
           <image class="pic" src="{{item.pic}}" mode="" data-prodId="{{item.prodId}}" bind:tap="toProdPage" />
           <view class="info">

+ 9 - 4
pages/category1/category.js

@@ -81,10 +81,15 @@ Page({
         index:this.data.subIndex+1
       }
     }}
-    this.onleftMenuTab(data)
-    // this.setData({
-    //   topHeight:0
-    // })
+    
+    this.setData({
+      topHeight:15
+    },() => {
+      // 3. 延迟恢复样式(避免视觉闪烁)
+      setTimeout(() => {
+        this.onleftMenuTab(data)
+      }, 0);
+    })
   },
   handleSale(){
     this.setData({

+ 1 - 1
pages/category1/category.wxml

@@ -83,7 +83,7 @@
 
     <!-- 右侧内容start -->
     <!-- scroll-view  -->
-    <view scroll-y="true" class='rightcontent' 	enable-passive scroll-into-view="{{rightView}}"	upper-threshold="10" 	lower-threshold="10"  scroll-top="{{topHeight}}" bindscroll="scroll"bindscrolltoupper="scrollTop" bindscrolltolower="scrollBottom">
+    <view scroll-y="true" class='rightcontent' 	enable-passive scroll-into-view="{{rightView}}"	upper-threshold="10" 	lower-threshold="10"  scroll-top="{{topHeight}}" bindscroll="scroll" bindscrolltoupper="scrollTop" bindscrolltolower="scrollBottom">
       <image class="banner" src="../../images/imgs/banner.png" mode="" />
       <!-- <text wx:if="{{subCategoryList.length>0}}" class="sub-title" >{{subCategoryList[subIndex].categoryName}}</text> -->
     <view class="loading" wx:if="{{showLoading}}">