@@ -13,7 +13,7 @@ const defaultSidebarData = [
13
13
Component ( {
14
14
15
15
externalClasses : [
16
- 'l-tip-class' , 'l-tip-text-class' , 'l-sidebar-class' , 'l-selected-class' , 'l-unselected-class' , 'l-sidebar-item-class'
16
+ 'l-tip-class' , 'l-tip-text-class' , 'l-sidebar-class' , 'l-selected-class' , 'l-unselected-class' , 'l-sidebar-item-class'
17
17
] ,
18
18
19
19
relations : {
@@ -135,7 +135,7 @@ Component({
135
135
wx . lin = wx . lin || { } ;
136
136
// 传入scrollTop的值的函数
137
137
wx . lin . setScrollTop = ( scrollTop ) => {
138
- dataUtil . setDiffData ( this , { scrollTop} ) ;
138
+ dataUtil . setDiffData ( this , { scrollTop } ) ;
139
139
} ;
140
140
} ,
141
141
@@ -357,7 +357,7 @@ Component({
357
357
countCurrentActiveIndex ( scrollTop ) {
358
358
let result = 0 ;
359
359
// 每个 Anchor 距离页面顶部的 px 值
360
- const { anchorTopLocations} = this . data . _anchor ;
360
+ const { anchorTopLocations } = this . data . _anchor ;
361
361
362
362
for ( let i = 0 ; i < anchorTopLocations . length ; i ++ ) {
363
363
if ( scrollTop + this . data . _stickOffsetTopPx < anchorTopLocations [ i ] ) {
@@ -378,19 +378,18 @@ Component({
378
378
* @param event 事件对象
379
379
*/
380
380
onTouchMove ( event ) {
381
-
382
381
// 显示 Tip
383
382
this . switchTipShow ( true ) ;
384
383
// 标识正在滑动 Sidebar
385
384
this . switchIsMovingSidebar ( true ) ;
386
385
387
386
// 取出 Sidebar 位置信息
388
- const { top : sidebarTop , sidebarItemHeight} = this . data . _sidebar ;
387
+ const { top : sidebarTop , sidebarItemHeight } = this . data . _sidebar ;
389
388
// Sidebar 索引个数
390
389
const sidebarLength = this . data . sidebarData . length ;
391
390
// 触摸点 Y 坐标
392
391
const touchY = event . touches [ 0 ] . clientY ;
393
- // 计算当前触摸点在第几个索引除
392
+ // 计算当前触摸点在第几个索引处
394
393
let index = Math . floor ( ( touchY - sidebarTop ) / sidebarItemHeight ) ;
395
394
396
395
// 滑动超过范围时限制索引边界值
@@ -417,15 +416,24 @@ Component({
417
416
scrollTop : scrollPageToLocation
418
417
} ) ;
419
418
419
+ /**
420
+ * fix issue1078
421
+ * 当点击 sidebar 时,onTouchend 会先于 onTouchMove 执行
422
+ * 导致滑动状态无法正常关闭,固此处添加一个延时状态修改(页面滚动需要一定时间)
423
+ */
424
+ event . type === 'tap' && setTimeout ( ( ) => {
425
+ this . switchIsMovingSidebar ( false ) ;
426
+ } , 100 ) ;
427
+
420
428
// 触发 linselected 事件
421
- eventUtil . emit ( this , 'linselected' , { index, tipText} ) ;
429
+ eventUtil . emit ( this , 'linselected' , { index, tipText } ) ;
422
430
} ,
423
431
424
432
/**
425
433
* 监听 手指触摸动作结束 事件
426
434
*/
427
435
onTouchend ( ) {
428
- // 300 毫秒后隐藏 Tip
436
+ // 500 毫秒后隐藏 Tip
429
437
setTimeout ( ( ) => {
430
438
this . switchTipShow ( false ) ;
431
439
} , 500 ) ;
0 commit comments