Skip to content

Commit

Permalink
fix(h5): 修复 Taro.pageScrollTo 报错,fix #9152
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj authored and ZakaryCode committed Apr 26, 2021
1 parent 51b86f8 commit af6561c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/taro-h5/src/api/scroll/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ export const pageScrollTo = ({ scrollTop, selector, duration = 300, success, fai
console.warn('"scrollTop" 或 "selector" 建议只设一个值,全部设置会忽略selector')
}
const from = scrollFunc()
const to = scrollTop || document.querySelector(selector).offsetTop
let to
if (typeof scrollTop === 'number') {
to = scrollTop
} else {
to = document.querySelector(selector).offsetTop
}
const delta = to - from

const frameCnt = duration / FRAME_DURATION
Expand Down

0 comments on commit af6561c

Please sign in to comment.