word 搜索优化
This commit is contained in:
parent
5b7c792ab4
commit
6567c0f7b6
|
|
@ -533,12 +533,22 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wrapperRect = wrapper.getBoundingClientRect()
|
||||||
|
const margin = 24
|
||||||
|
|
||||||
|
const isInViewport = targetRect.top >= wrapperRect.top + margin &&
|
||||||
|
targetRect.bottom <= wrapperRect.bottom - margin &&
|
||||||
|
targetRect.left >= wrapperRect.left &&
|
||||||
|
targetRect.right <= wrapperRect.right
|
||||||
|
|
||||||
|
if (isInViewport) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const performScroll = () => {
|
const performScroll = () => {
|
||||||
try {
|
try {
|
||||||
const wrapperRect = wrapper.getBoundingClientRect()
|
|
||||||
const currentScrollTop = wrapper.scrollTop
|
const currentScrollTop = wrapper.scrollTop
|
||||||
const targetTopRelativeToWrapper = targetRect.top - wrapperRect.top + currentScrollTop
|
const targetTopRelativeToWrapper = targetRect.top - wrapperRect.top + currentScrollTop
|
||||||
const margin = 24
|
|
||||||
const desiredScrollTop = Math.max(targetTopRelativeToWrapper - margin, 0)
|
const desiredScrollTop = Math.max(targetTopRelativeToWrapper - margin, 0)
|
||||||
|
|
||||||
if (useSmoothScroll) {
|
if (useSmoothScroll) {
|
||||||
|
|
@ -555,7 +565,6 @@ export default {
|
||||||
absoluteTop += node.offsetTop || 0
|
absoluteTop += node.offsetTop || 0
|
||||||
node = node.offsetParent
|
node = node.offsetParent
|
||||||
}
|
}
|
||||||
const margin = 24
|
|
||||||
const desiredScrollTop = Math.max(absoluteTop - margin, 0)
|
const desiredScrollTop = Math.max(absoluteTop - margin, 0)
|
||||||
|
|
||||||
if (useSmoothScroll) {
|
if (useSmoothScroll) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue