[bugfix] IndexBar: Select event repeated trigger (#3409)

This commit is contained in:
dongj0316
2019-05-30 18:57:53 +08:00
committed by neverland
parent 1c6feaa650
commit 0678c7d30b
3 changed files with 12 additions and 7 deletions

View File

@@ -136,15 +136,19 @@ export default sfc({
const { clientX, clientY } = event.touches[0];
const target = document.elementFromPoint(clientX, clientY);
this.scrollToElement(target);
if (target) {
const { idx } = target.dataset;
/* istanbul ignore else */
if (this.touchActiveIdx !== idx) {
this.touchActiveIdx = idx;
this.scrollToElement(target);
}
}
}
},
scrollToElement(element, setActive) {
if (!element) {
return;
}
const { index } = element.dataset;
if (!index) {
return;
@@ -178,6 +182,7 @@ export default sfc({
<span
class={bem('index')}
style={idx === this.activeAnchorIndex ? this.highlightStyle : null}
data-idx={idx}
data-index={index}
>
{index}