@tarojs/taro-h5 3.5.0-alpha.16 → 3.5.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/ui/scroll/index.js +5 -5
- package/dist/index.cjs.js +5 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +5 -5
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -4
package/dist/index.esm.js
CHANGED
|
@@ -4510,7 +4510,7 @@ const FRAME_DURATION = 17;
|
|
|
4510
4510
|
/**
|
|
4511
4511
|
* 将页面滚动到目标位置
|
|
4512
4512
|
*/
|
|
4513
|
-
const pageScrollTo = ({ scrollTop, selector = '', duration = 300, success, fail, complete }) => {
|
|
4513
|
+
const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300, success, fail, complete }) => {
|
|
4514
4514
|
let scrollFunc;
|
|
4515
4515
|
const handle = new MethodHandler({ name: 'pageScrollTo', success, fail, complete });
|
|
4516
4516
|
return new Promise((resolve, reject) => {
|
|
@@ -4553,12 +4553,12 @@ const pageScrollTo = ({ scrollTop, selector = '', duration = 300, success, fail,
|
|
|
4553
4553
|
}
|
|
4554
4554
|
const from = scrollFunc();
|
|
4555
4555
|
let to;
|
|
4556
|
-
if (
|
|
4557
|
-
|
|
4556
|
+
if (selector) {
|
|
4557
|
+
const el = document.querySelector(selector);
|
|
4558
|
+
to = ((el === null || el === void 0 ? void 0 : el.offsetTop) || 0) + offsetTop;
|
|
4558
4559
|
}
|
|
4559
4560
|
else {
|
|
4560
|
-
|
|
4561
|
-
to = (el === null || el === void 0 ? void 0 : el.offsetTop) || 0;
|
|
4561
|
+
to = typeof scrollTop === 'number' ? scrollTop : 0;
|
|
4562
4562
|
}
|
|
4563
4563
|
const delta = to - from;
|
|
4564
4564
|
const frameCnt = duration / FRAME_DURATION;
|