Skip to content

Commit 02140b5

Browse files
committed
fix: indexbar scroll not silky
1 parent cf6c7bf commit 02140b5

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

mini.project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"skipTranspile": false,
1515
"minify": false,
1616
"sourcemap": false,
17-
"lazyCompile": true
17+
"lazyCompile": false
1818
}
1919
}

src/IndexBar/index.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,19 @@ Component(
2929
? current
3030
: defaultCurrent;
3131
const _index = items?.findIndex((u) => initCurrent === u.label);
32-
this.setData({
33-
currentKey: _index,
34-
touchKeyIndex: _index,
35-
touchKey: initCurrent,
36-
});
32+
this.setData(
33+
{
34+
currentKey: _index,
35+
touchKeyIndex: _index,
36+
touchKey: initCurrent,
37+
},
38+
() => {
39+
this.setData({
40+
touchKeyIndex: -1,
41+
touchKey: '',
42+
});
43+
}
44+
);
3745
},
3846
isControlled(nextProps, valueKey = 'current') {
3947
if ('controlled' in nextProps) {
@@ -129,8 +137,6 @@ Component(
129137
if (currentKey !== newIndex - 1 && newIndex - 1 >= 0 && !moving) {
130138
this.setData({
131139
currentKey: newIndex - 1,
132-
touchKeyIndex: newIndex - 1,
133-
touchKey: items[newIndex - 1].label,
134140
});
135141
this.onAlphabetClick(items[newIndex - 1], newIndex - 1);
136142
}

0 commit comments

Comments
 (0)