pdf搜索优化
This commit is contained in:
parent
ed03901ba8
commit
775210ba49
|
|
@ -823,30 +823,16 @@ export default {
|
||||||
if (!target) return
|
if (!target) return
|
||||||
const wrapper = this.$refs.pdfWrapper
|
const wrapper = this.$refs.pdfWrapper
|
||||||
if (!wrapper) return
|
if (!wrapper) return
|
||||||
|
|
||||||
if (!useSmoothScroll) {
|
|
||||||
// 直接跳转到匹配位置,不做平滑滚动动画
|
|
||||||
try {
|
|
||||||
target.scrollIntoView({
|
|
||||||
behavior: 'auto',
|
|
||||||
block: 'center',
|
|
||||||
inline: 'nearest',
|
|
||||||
})
|
|
||||||
} catch (e) {
|
|
||||||
// 兼容性兜底
|
|
||||||
const container = target.closest('.pdf-page') || target
|
const container = target.closest('.pdf-page') || target
|
||||||
if (!container) return
|
if (!container) return
|
||||||
const wrapperOffsetTop = container.offsetTop
|
|
||||||
const containerHeight = container.offsetHeight || target.offsetHeight || 0
|
// 不做平滑动画,直接把匹配所在的 pdf-page 翻到可视区域
|
||||||
const desired = wrapperOffsetTop - Math.max((wrapper.clientHeight - containerHeight) / 2, 0)
|
if (!useSmoothScroll) {
|
||||||
this.cancelScrollAnimation()
|
this.cancelScrollAnimation()
|
||||||
wrapper.scrollTop = desired
|
wrapper.scrollTop = container.offsetTop
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const container = target.closest('.pdf-page') || target
|
|
||||||
if (!container) return
|
|
||||||
const wrapperOffsetTop = container.offsetTop
|
const wrapperOffsetTop = container.offsetTop
|
||||||
const containerHeight = container.offsetHeight || target.offsetHeight || 0
|
const containerHeight = container.offsetHeight || target.offsetHeight || 0
|
||||||
const desired = wrapperOffsetTop - Math.max((wrapper.clientHeight - containerHeight) / 2, 0)
|
const desired = wrapperOffsetTop - Math.max((wrapper.clientHeight - containerHeight) / 2, 0)
|
||||||
|
|
@ -1369,7 +1355,6 @@ export default {
|
||||||
padding: 24px;
|
padding: 24px;
|
||||||
background: #eaeaea;
|
background: #eaeaea;
|
||||||
position: relative;
|
position: relative;
|
||||||
scroll-behavior: smooth;
|
|
||||||
overscroll-behavior: contain;
|
overscroll-behavior: contain;
|
||||||
scrollbar-gutter: stable both-edges;
|
scrollbar-gutter: stable both-edges;
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue