@tarojs/taro-h5 3.5.0 → 3.5.1

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.
@@ -9,7 +9,7 @@ export const canvasToTempFilePath = ({ canvasId, fileType, quality, success, fai
9
9
  const el = findDOM(inst);
10
10
  const canvas = el === null || el === void 0 ? void 0 : el.querySelector(`canvas[canvas-id="${canvasId}"]`);
11
11
  try {
12
- const dataURL = canvas === null || canvas === void 0 ? void 0 : canvas.toDataURL(`image/${fileType || 'png'}`, quality);
12
+ const dataURL = canvas === null || canvas === void 0 ? void 0 : canvas.toDataURL(`image/${(fileType === 'jpg' ? 'jpeg' : fileType) || 'png'}`, quality);
13
13
  return handle.success({
14
14
  tempFilePath: dataURL
15
15
  });
@@ -6,7 +6,7 @@ const FRAME_DURATION = 17;
6
6
  /**
7
7
  * 将页面滚动到目标位置
8
8
  */
9
- export const pageScrollTo = ({ scrollTop, selector = '', duration = 300, success, fail, complete }) => {
9
+ export const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300, success, fail, complete }) => {
10
10
  let scrollFunc;
11
11
  const handle = new MethodHandler({ name: 'pageScrollTo', success, fail, complete });
12
12
  return new Promise((resolve, reject) => {
@@ -49,12 +49,12 @@ export const pageScrollTo = ({ scrollTop, selector = '', duration = 300, success
49
49
  }
50
50
  const from = scrollFunc();
51
51
  let to;
52
- if (typeof scrollTop === 'number') {
53
- to = scrollTop;
52
+ if (selector) {
53
+ const el = document.querySelector(selector);
54
+ to = ((el === null || el === void 0 ? void 0 : el.offsetTop) || 0) + offsetTop;
54
55
  }
55
56
  else {
56
- const el = document.querySelector(selector);
57
- to = (el === null || el === void 0 ? void 0 : el.offsetTop) || 0;
57
+ to = typeof scrollTop === 'number' ? scrollTop : 0;
58
58
  }
59
59
  const delta = to - from;
60
60
  const frameCnt = duration / FRAME_DURATION;
package/dist/index.cjs.js CHANGED
@@ -1030,7 +1030,7 @@ const canvasToTempFilePath = ({ canvasId, fileType, quality, success, fail, comp
1030
1030
  const el = findDOM(inst);
1031
1031
  const canvas = el === null || el === void 0 ? void 0 : el.querySelector(`canvas[canvas-id="${canvasId}"]`);
1032
1032
  try {
1033
- const dataURL = canvas === null || canvas === void 0 ? void 0 : canvas.toDataURL(`image/${fileType || 'png'}`, quality);
1033
+ const dataURL = canvas === null || canvas === void 0 ? void 0 : canvas.toDataURL(`image/${(fileType === 'jpg' ? 'jpeg' : fileType) || 'png'}`, quality);
1034
1034
  return handle.success({
1035
1035
  tempFilePath: dataURL
1036
1036
  });
@@ -4518,7 +4518,7 @@ const FRAME_DURATION = 17;
4518
4518
  /**
4519
4519
  * 将页面滚动到目标位置
4520
4520
  */
4521
- const pageScrollTo = ({ scrollTop, selector = '', duration = 300, success, fail, complete }) => {
4521
+ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300, success, fail, complete }) => {
4522
4522
  let scrollFunc;
4523
4523
  const handle = new MethodHandler({ name: 'pageScrollTo', success, fail, complete });
4524
4524
  return new Promise((resolve, reject) => {
@@ -4561,12 +4561,12 @@ const pageScrollTo = ({ scrollTop, selector = '', duration = 300, success, fail,
4561
4561
  }
4562
4562
  const from = scrollFunc();
4563
4563
  let to;
4564
- if (typeof scrollTop === 'number') {
4565
- to = scrollTop;
4564
+ if (selector) {
4565
+ const el = document.querySelector(selector);
4566
+ to = ((el === null || el === void 0 ? void 0 : el.offsetTop) || 0) + offsetTop;
4566
4567
  }
4567
4568
  else {
4568
- const el = document.querySelector(selector);
4569
- to = (el === null || el === void 0 ? void 0 : el.offsetTop) || 0;
4569
+ to = typeof scrollTop === 'number' ? scrollTop : 0;
4570
4570
  }
4571
4571
  const delta = to - from;
4572
4572
  const frameCnt = duration / FRAME_DURATION;