提交 9b1dd076 编写于 作者: D DCloud_LXH

fix: pageScrollTo selector question/109566

上级 9c626ab8
export const pageScrollTo = { export const pageScrollTo = {
scrollTop: { scrollTop: {
type: Number, type: Number
required: true
}, },
duration: { duration: {
type: Number, type: Number,
...@@ -10,4 +9,4 @@ export const pageScrollTo = { ...@@ -10,4 +9,4 @@ export const pageScrollTo = {
params.duration = Math.max(0, duration) params.duration = Math.max(0, duration)
} }
} }
} }
...@@ -8,8 +8,19 @@ export function disableScroll (evt) { ...@@ -8,8 +8,19 @@ export function disableScroll (evt) {
export function pageScrollTo ({ export function pageScrollTo ({
scrollTop, scrollTop,
selector,
duration duration
}) { }) {
if (typeof scrollTop === 'undefined') {
const el = document.querySelector(selector)
if (el) {
const { top, height } = el.getBoundingClientRect()
scrollTop = top + window.pageYOffset
if (__PLATFORM__ === 'h5') {
scrollTop -= height
}
}
}
const documentElement = document.documentElement const documentElement = document.documentElement
const { const {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册