标签:列表 component element clientx script one asc set mount
componentDidMount() {
this.move();
}
skipToDep(e) {
let dom = document.getElementById(e); // 获取要跳至的字母节点
if (e === ‘#‘) {
this.props.scroller.scrollTo(0, 0);
} else {
this.props.scroller.scrollTo(0, -dom.offsetTop);
}
}
move() {
// 监听字母导航列表的touchmove事件
this.navigation.addEventListener(‘touchmove‘, e => {
const node = document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY); // 获取move时对应的节点
const reg = /^(#|[A-Z])/;
if(reg.test(node.innerText)) {
this.skipToDep(node.innerText);
}
});
}
标签:列表 component element clientx script one asc set mount
原文地址:https://www.cnblogs.com/ljwk/p/9929993.html