@tarojs/taro-h5 3.7.0-alpha.1 → 3.7.0-alpha.2
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/ai/index.d.ts +2 -2
- package/dist/api/base/index.d.ts +7 -7
- package/dist/api/canvas/index.d.ts +4 -4
- package/dist/api/device/index.d.ts +23 -23
- package/dist/api/index.d.ts +24 -24
- package/dist/api/location/index.d.ts +2 -2
- package/dist/api/media/audio/InnerAudioContext.d.ts +1 -1
- package/dist/api/media/background-audio/BackgroundAudioManager.d.ts +1 -1
- package/dist/api/media/background-audio/index.d.ts +1 -1
- package/dist/api/media/image/index.d.ts +3 -3
- package/dist/api/media/index.d.ts +12 -12
- package/dist/api/network/index.d.ts +7 -7
- package/dist/api/open-api/index.d.ts +18 -18
- package/dist/api/storage/index.d.ts +1 -1
- package/dist/api/ui/index.d.ts +12 -12
- package/dist/api/wxml/IntersectionObserver.js +7 -7
- package/dist/api/wxml/IntersectionObserver.js.map +1 -1
- package/dist/api/wxml/nodesRef.d.ts +1 -1
- package/dist/api/wxml/selectorQuery.d.ts +1 -1
- package/dist/index.cjs.js +7 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.esm.js +7 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/utils/index.d.ts +3 -3
- package/package.json +6 -6
package/dist/api/ai/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./facial
|
|
2
|
-
export * from "./visual
|
|
1
|
+
export * from "./facial";
|
|
2
|
+
export * from "./visual";
|
package/dist/api/base/index.d.ts
CHANGED
|
@@ -8,10 +8,10 @@ declare const canIUse: (option?: {}, ...args: any[]) => Promise<Partial<TaroGene
|
|
|
8
8
|
declare function arrayBufferToBase64(arrayBuffer: ArrayBuffer): string;
|
|
9
9
|
declare function base64ToArrayBuffer(base64: string): Uint8Array;
|
|
10
10
|
export { env, canIUse, arrayBufferToBase64, base64ToArrayBuffer };
|
|
11
|
-
export * from "./crypto
|
|
12
|
-
export * from "./debug
|
|
13
|
-
export * from "./performance
|
|
14
|
-
export * from "./system
|
|
15
|
-
export * from "./update
|
|
16
|
-
export * from "./weapp/app-event
|
|
17
|
-
export * from "./weapp/life-cycle
|
|
11
|
+
export * from "./crypto";
|
|
12
|
+
export * from "./debug";
|
|
13
|
+
export * from "./performance";
|
|
14
|
+
export * from "./system";
|
|
15
|
+
export * from "./update";
|
|
16
|
+
export * from "./weapp/app-event";
|
|
17
|
+
export * from "./weapp/life-cycle";
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
declare const createOffscreenCanvas: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
3
3
|
export { createOffscreenCanvas };
|
|
4
4
|
/** 创建 canvas 的绘图上下文 CanvasContext 对象 */
|
|
5
|
-
export * from "./createCanvasContext
|
|
5
|
+
export * from "./createCanvasContext";
|
|
6
6
|
/** 把当前画布指定区域的内容导出生成指定大小的图片 */
|
|
7
|
-
export * from "./canvasToTempFilePath
|
|
7
|
+
export * from "./canvasToTempFilePath";
|
|
8
8
|
/** 将像素数据绘制到画布 */
|
|
9
|
-
export * from "./canvasPutImageData
|
|
9
|
+
export * from "./canvasPutImageData";
|
|
10
10
|
/** 获取 canvas 区域隐含的像素数据 */
|
|
11
|
-
export * from "./canvasGetImageData
|
|
11
|
+
export * from "./canvasGetImageData";
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export * from "./accelerometer
|
|
2
|
-
export * from "./accessibility
|
|
3
|
-
export * from "./battery
|
|
4
|
-
export * from "./bluetooth
|
|
5
|
-
export * from "./bluetooth-ble
|
|
6
|
-
export * from "./bluetooth-peripheral
|
|
7
|
-
export * from "./calendar
|
|
8
|
-
export * from "./clipboard
|
|
9
|
-
export * from "./compass
|
|
10
|
-
export * from "./contact
|
|
11
|
-
export * from "./crypto
|
|
12
|
-
export * from "./gyroscope
|
|
13
|
-
export * from "./iBeacon
|
|
14
|
-
export * from "./keyboard
|
|
15
|
-
export * from "./memory
|
|
16
|
-
export * from "./motion
|
|
17
|
-
export * from "./network
|
|
18
|
-
export * from "./nfc
|
|
19
|
-
export * from "./phone
|
|
20
|
-
export * from "./scan
|
|
21
|
-
export * from "./screen
|
|
22
|
-
export * from "./vibrate
|
|
23
|
-
export * from "./wifi
|
|
1
|
+
export * from "./accelerometer";
|
|
2
|
+
export * from "./accessibility";
|
|
3
|
+
export * from "./battery";
|
|
4
|
+
export * from "./bluetooth";
|
|
5
|
+
export * from "./bluetooth-ble";
|
|
6
|
+
export * from "./bluetooth-peripheral";
|
|
7
|
+
export * from "./calendar";
|
|
8
|
+
export * from "./clipboard";
|
|
9
|
+
export * from "./compass";
|
|
10
|
+
export * from "./contact";
|
|
11
|
+
export * from "./crypto";
|
|
12
|
+
export * from "./gyroscope";
|
|
13
|
+
export * from "./iBeacon";
|
|
14
|
+
export * from "./keyboard";
|
|
15
|
+
export * from "./memory";
|
|
16
|
+
export * from "./motion";
|
|
17
|
+
export * from "./network";
|
|
18
|
+
export * from "./nfc";
|
|
19
|
+
export * from "./phone";
|
|
20
|
+
export * from "./scan";
|
|
21
|
+
export * from "./screen";
|
|
22
|
+
export * from "./vibrate";
|
|
23
|
+
export * from "./wifi";
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export * from "./ad/index
|
|
2
|
-
export * from "./ai/index
|
|
3
|
-
export * from "./alipay/index
|
|
4
|
-
export * from "./base/index
|
|
5
|
-
export * from "./canvas/index
|
|
6
|
-
export * from "./cloud/index
|
|
7
|
-
export * from "./data-analysis/index
|
|
8
|
-
export * from "./device/index
|
|
9
|
-
export * from "./ext/index
|
|
10
|
-
export * from "./files/index
|
|
11
|
-
export * from "./framework/index
|
|
12
|
-
export * from "./location/index
|
|
13
|
-
export * from "./media/index
|
|
14
|
-
export * from "./navigate/index
|
|
15
|
-
export * from "./network/index
|
|
16
|
-
export * from "./open-api/index
|
|
17
|
-
export * from "./payment/index
|
|
18
|
-
export * from "./route/index
|
|
19
|
-
export * from "./share/index
|
|
20
|
-
export * from "./storage/index
|
|
21
|
-
export * from "./swan/index
|
|
22
|
-
export * from "./ui/index
|
|
23
|
-
export * from "./worker/index
|
|
24
|
-
export * from "./wxml/index
|
|
1
|
+
export * from "./ad/index";
|
|
2
|
+
export * from "./ai/index";
|
|
3
|
+
export * from "./alipay/index";
|
|
4
|
+
export * from "./base/index";
|
|
5
|
+
export * from "./canvas/index";
|
|
6
|
+
export * from "./cloud/index";
|
|
7
|
+
export * from "./data-analysis/index";
|
|
8
|
+
export * from "./device/index";
|
|
9
|
+
export * from "./ext/index";
|
|
10
|
+
export * from "./files/index";
|
|
11
|
+
export * from "./framework/index";
|
|
12
|
+
export * from "./location/index";
|
|
13
|
+
export * from "./media/index";
|
|
14
|
+
export * from "./navigate/index";
|
|
15
|
+
export * from "./network/index";
|
|
16
|
+
export * from "./open-api/index";
|
|
17
|
+
export * from "./payment/index";
|
|
18
|
+
export * from "./route/index";
|
|
19
|
+
export * from "./share/index";
|
|
20
|
+
export * from "./storage/index";
|
|
21
|
+
export * from "./swan/index";
|
|
22
|
+
export * from "./ui/index";
|
|
23
|
+
export * from "./worker/index";
|
|
24
|
+
export * from "./wxml/index";
|
|
@@ -11,5 +11,5 @@ declare const offLocationChange: (option?: {}, ...args: any[]) => Promise<Partia
|
|
|
11
11
|
declare const choosePoi: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
12
12
|
declare const getFuzzyLocation: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
13
13
|
export { stopLocationUpdate, startLocationUpdateBackground, startLocationUpdate, openLocation, onLocationChangeError, onLocationChange, offLocationChangeError, offLocationChange, choosePoi, getFuzzyLocation };
|
|
14
|
-
export { getLocation } from "./getLocation
|
|
15
|
-
export { chooseLocation } from "./chooseLocation
|
|
14
|
+
export { getLocation } from "./getLocation";
|
|
15
|
+
export { chooseLocation } from "./chooseLocation";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
|
-
import { CallbackManager } from "../../../utils/handler
|
|
2
|
+
import { CallbackManager } from "../../../utils/handler";
|
|
3
3
|
declare class InnerAudioContext implements Taro.InnerAudioContext {
|
|
4
4
|
Instance?: HTMLAudioElement;
|
|
5
5
|
errorStack: CallbackManager;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
|
-
import { CallbackManager } from "../../../utils/handler
|
|
2
|
+
import { CallbackManager } from "../../../utils/handler";
|
|
3
3
|
declare class BackgroundAudioManager implements Taro.BackgroundAudioManager {
|
|
4
4
|
Instance?: HTMLAudioElement;
|
|
5
5
|
errorStack: CallbackManager;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BackgroundAudioManager } from "./BackgroundAudioManager
|
|
1
|
+
import { BackgroundAudioManager } from "./BackgroundAudioManager";
|
|
2
2
|
declare const stopBackgroundAudio: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
3
3
|
declare const seekBackgroundAudio: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
4
4
|
declare const playBackgroundAudio: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
@@ -3,6 +3,6 @@ declare const previewMedia: (option?: {}, ...args: any[]) => Promise<Partial<Tar
|
|
|
3
3
|
declare const compressImage: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
4
4
|
declare const chooseMessageFile: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
5
5
|
export { saveImageToPhotosAlbum, previewMedia, compressImage, chooseMessageFile };
|
|
6
|
-
export * from "./getImageInfo
|
|
7
|
-
export * from "./previewImage
|
|
8
|
-
export * from "./chooseImage
|
|
6
|
+
export * from "./getImageInfo";
|
|
7
|
+
export * from "./previewImage";
|
|
8
|
+
export * from "./chooseImage";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export * from "./audio/index
|
|
2
|
-
export * from "./background-audio/index
|
|
3
|
-
export * from "./camera
|
|
4
|
-
export * from "./image/index
|
|
5
|
-
export * from "./live
|
|
6
|
-
export * from "./map
|
|
7
|
-
export * from "./media-recorder
|
|
8
|
-
export * from "./recorder
|
|
9
|
-
export * from "./video/index
|
|
10
|
-
export * from "./video-decoder
|
|
11
|
-
export * from "./video-processing
|
|
12
|
-
export * from "./voip
|
|
1
|
+
export * from "./audio/index";
|
|
2
|
+
export * from "./background-audio/index";
|
|
3
|
+
export * from "./camera";
|
|
4
|
+
export * from "./image/index";
|
|
5
|
+
export * from "./live";
|
|
6
|
+
export * from "./map";
|
|
7
|
+
export * from "./media-recorder";
|
|
8
|
+
export * from "./recorder";
|
|
9
|
+
export * from "./video/index";
|
|
10
|
+
export * from "./video-decoder";
|
|
11
|
+
export * from "./video-processing";
|
|
12
|
+
export * from "./voip";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./download
|
|
2
|
-
export * from "./mdns
|
|
3
|
-
export * from "./request/index
|
|
4
|
-
export * from "./tcp
|
|
5
|
-
export * from "./udp
|
|
6
|
-
export * from "./upload
|
|
7
|
-
export * from "./websocket/index
|
|
1
|
+
export * from "./download";
|
|
2
|
+
export * from "./mdns";
|
|
3
|
+
export * from "./request/index";
|
|
4
|
+
export * from "./tcp";
|
|
5
|
+
export * from "./udp";
|
|
6
|
+
export * from "./upload";
|
|
7
|
+
export * from "./websocket/index";
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export * from "./account
|
|
2
|
-
export * from "./address
|
|
3
|
-
export * from "./authorize
|
|
4
|
-
export * from "./card
|
|
5
|
-
export * from "./channels-live
|
|
6
|
-
export * from "./customer-service
|
|
7
|
-
export * from "./facial
|
|
8
|
-
export * from "./favorites
|
|
9
|
-
export * from "./group
|
|
10
|
-
export * from "./invoice
|
|
11
|
-
export * from "./license-plate
|
|
12
|
-
export * from "./login
|
|
13
|
-
export * from "./red-package
|
|
14
|
-
export * from "./settings
|
|
15
|
-
export * from "./soter
|
|
16
|
-
export * from "./subscribe-message
|
|
17
|
-
export * from "./user-info
|
|
18
|
-
export * from "./werun
|
|
1
|
+
export * from "./account";
|
|
2
|
+
export * from "./address";
|
|
3
|
+
export * from "./authorize";
|
|
4
|
+
export * from "./card";
|
|
5
|
+
export * from "./channels-live";
|
|
6
|
+
export * from "./customer-service";
|
|
7
|
+
export * from "./facial";
|
|
8
|
+
export * from "./favorites";
|
|
9
|
+
export * from "./group";
|
|
10
|
+
export * from "./invoice";
|
|
11
|
+
export * from "./license-plate";
|
|
12
|
+
export * from "./login";
|
|
13
|
+
export * from "./red-package";
|
|
14
|
+
export * from "./settings";
|
|
15
|
+
export * from "./soter";
|
|
16
|
+
export * from "./subscribe-message";
|
|
17
|
+
export * from "./user-info";
|
|
18
|
+
export * from "./werun";
|
|
@@ -12,4 +12,4 @@ declare const createBufferURL: (option?: {}, ...args: any[]) => Promise<Partial<
|
|
|
12
12
|
declare const clearStorageSync: typeof Taro.clearStorageSync;
|
|
13
13
|
declare const clearStorage: typeof Taro.clearStorage;
|
|
14
14
|
export { setStorageSync, setStorage, revokeBufferURL, removeStorageSync, removeStorage, getStorageSync, getStorageInfoSync, getStorageInfo, getStorage, createBufferURL, clearStorageSync, clearStorage };
|
|
15
|
-
export * from "./background-fetch
|
|
15
|
+
export * from "./background-fetch";
|
package/dist/api/ui/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export * from "./animation/index
|
|
2
|
-
export * from "./background
|
|
3
|
-
export * from "./custom-component
|
|
4
|
-
export * from "./fonts
|
|
5
|
-
export * from "./interaction/index
|
|
6
|
-
export * from "./menu
|
|
7
|
-
export * from "./navigation-bar/index
|
|
8
|
-
export * from "./pull-down-refresh
|
|
9
|
-
export * from "./scroll/index
|
|
10
|
-
export * from "./sticky
|
|
11
|
-
export * from "./tab-bar
|
|
12
|
-
export * from "./window
|
|
1
|
+
export * from "./animation/index";
|
|
2
|
+
export * from "./background";
|
|
3
|
+
export * from "./custom-component";
|
|
4
|
+
export * from "./fonts";
|
|
5
|
+
export * from "./interaction/index";
|
|
6
|
+
export * from "./menu";
|
|
7
|
+
export * from "./navigation-bar/index";
|
|
8
|
+
export * from "./pull-down-refresh";
|
|
9
|
+
export * from "./scroll/index";
|
|
10
|
+
export * from "./sticky";
|
|
11
|
+
export * from "./tab-bar";
|
|
12
|
+
export * from "./window";
|
|
@@ -3,13 +3,6 @@ import { findDOM } from '../../utils/index.js';
|
|
|
3
3
|
// pollify
|
|
4
4
|
import('intersection-observer');
|
|
5
5
|
class TaroH5IntersectionObserver {
|
|
6
|
-
// selector 的容器节点
|
|
7
|
-
get container() {
|
|
8
|
-
const container = (this._component !== null
|
|
9
|
-
? (findDOM(this._component) || document)
|
|
10
|
-
: document);
|
|
11
|
-
return container;
|
|
12
|
-
}
|
|
13
6
|
constructor(component, options = {}) {
|
|
14
7
|
// 选项
|
|
15
8
|
this._options = {
|
|
@@ -26,6 +19,13 @@ class TaroH5IntersectionObserver {
|
|
|
26
19
|
this._component = component;
|
|
27
20
|
Object.assign(this._options, options);
|
|
28
21
|
}
|
|
22
|
+
// selector 的容器节点
|
|
23
|
+
get container() {
|
|
24
|
+
const container = (this._component !== null
|
|
25
|
+
? (findDOM(this._component) || document)
|
|
26
|
+
: document);
|
|
27
|
+
return container;
|
|
28
|
+
}
|
|
29
29
|
createInst() {
|
|
30
30
|
// 去除原本的实例
|
|
31
31
|
this.disconnect();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntersectionObserver.js","sources":["../../../src/api/wxml/IntersectionObserver.ts"],"sourcesContent":["import Taro from '@tarojs/taro'\n\nimport { findDOM } from '../../utils'\n// pollify\nimport('intersection-observer')\n\ntype TElement = Document | HTMLElement | Element\n\ntype TListener = {\n element: Element\n callback: Taro.IntersectionObserver.ObserveCallback\n}\n\nexport class TaroH5IntersectionObserver implements Taro.IntersectionObserver {\n\n // 自定义组件实例\n private _component: TaroGeneral.IAnyObject\n // 选项\n private _options = {\n thresholds: [0],\n initialRatio: 0,\n observeAll: false\n }\n\n // Observer实例\n private _observerInst: IntersectionObserver\n // 监控中的选择器\n private _listeners: TListener[] = []\n // 参照区域\n private _root: Element | null\n // 用来扩展(或收缩)参照节点布局区域的边界\n private _rootMargin: Taro.IntersectionObserver.RelativeToViewportMargins = {}\n // 是否已初始化\n private _isInited = false\n\n // selector 的容器节点\n protected get container () {\n const container: TElement = (\n this._component !== null \n ? (findDOM(this._component) as HTMLElement || document) \n : document\n )\n return container\n }\n\n constructor (component: TaroGeneral.IAnyObject, options: Taro.createIntersectionObserver.Option = {}) {\n this._component = component\n Object.assign(this._options, options)\n }\n\n private createInst () {\n // 去除原本的实例\n this.disconnect()\n\n const { left = 0, top = 0, bottom = 0, right = 0 } = this._rootMargin\n return new IntersectionObserver(entries => {\n entries.forEach(entry => {\n const _callback = this._getCallbackByElement(entry.target)\n const result = {\n boundingClientRect: entry.boundingClientRect,\n intersectionRatio: entry.intersectionRatio,\n intersectionRect: entry.intersectionRect,\n relativeRect: entry.rootBounds || { left: 0, right: 0, top: 0, bottom: 0 },\n time: entry.time\n }\n // web端会默认首次触发\n if (!this._isInited && this._options.initialRatio <= Math.min.apply(Math, this._options.thresholds)) {\n // 初始的相交比例,如果调用时检测到的相交比例与这个值不相等且达到阈值,则会触发一次监听器的回调函数。\n return\n }\n _callback && _callback.call(this, result)\n })\n this._isInited = true\n }, {\n root: this._root,\n rootMargin: [`${top}px`, `${right}px`, `${bottom}px`, `${left}px`].join(' '),\n threshold: this._options.thresholds\n })\n }\n\n public disconnect (): void {\n if (this._observerInst) {\n let listener\n while ((listener = this._listeners.pop())) {\n this._observerInst.unobserve(listener.element)\n }\n this._observerInst.disconnect()\n }\n }\n\n public observe (targetSelector: string, callback: Taro.IntersectionObserver.ObserveCallback): void {\n // 同wx小程序效果一致,每个实例监听一个Selector\n if (this._listeners.length) return\n // 监听前没有设置关联的节点\n if (!this._observerInst) {\n console.warn('Intersection observer will be ignored because no relative nodes are found.')\n return\n }\n \n const nodeList = this._options.observeAll \n ? this.container.querySelectorAll(targetSelector) \n : [this.container.querySelector(targetSelector)]\n \n nodeList.forEach(element => {\n if (!element) return\n this._observerInst.observe(element)\n this._listeners.push({ element, callback })\n })\n }\n\n public relativeTo (selector: string, margins?: Taro.IntersectionObserver.RelativeToMargins | undefined): Taro.IntersectionObserver {\n // 已设置observe监听后,重新关联节点\n if (this._listeners.length) {\n console.error('Relative nodes cannot be added after \"observe\" call in IntersectionObserver')\n return this\n }\n this._root = this.container.querySelector(selector) || null\n if (margins) {\n this._rootMargin = margins\n }\n this._observerInst = this.createInst()\n return this\n }\n\n public relativeToViewport (margins?: Taro.IntersectionObserver.RelativeToViewportMargins | undefined): Taro.IntersectionObserver {\n return this.relativeTo('.taro_page', margins)\n }\n\n private _getCallbackByElement (element: Element) {\n const listener = this._listeners.find(listener => listener.element === element)\n return listener ? listener.callback : null\n }\n\n}\n"],"names":[],"mappings":";;AAGA;AACA,OAAO,uBAAuB,CAAC,CAAA;MASlB,0BAA0B,CAAA
|
|
1
|
+
{"version":3,"file":"IntersectionObserver.js","sources":["../../../src/api/wxml/IntersectionObserver.ts"],"sourcesContent":["import Taro from '@tarojs/taro'\n\nimport { findDOM } from '../../utils'\n// pollify\nimport('intersection-observer')\n\ntype TElement = Document | HTMLElement | Element\n\ntype TListener = {\n element: Element\n callback: Taro.IntersectionObserver.ObserveCallback\n}\n\nexport class TaroH5IntersectionObserver implements Taro.IntersectionObserver {\n\n // 自定义组件实例\n private _component: TaroGeneral.IAnyObject\n // 选项\n private _options = {\n thresholds: [0],\n initialRatio: 0,\n observeAll: false\n }\n\n // Observer实例\n private _observerInst: IntersectionObserver\n // 监控中的选择器\n private _listeners: TListener[] = []\n // 参照区域\n private _root: Element | null\n // 用来扩展(或收缩)参照节点布局区域的边界\n private _rootMargin: Taro.IntersectionObserver.RelativeToViewportMargins = {}\n // 是否已初始化\n private _isInited = false\n\n // selector 的容器节点\n protected get container () {\n const container: TElement = (\n this._component !== null \n ? (findDOM(this._component) as HTMLElement || document) \n : document\n )\n return container\n }\n\n constructor (component: TaroGeneral.IAnyObject, options: Taro.createIntersectionObserver.Option = {}) {\n this._component = component\n Object.assign(this._options, options)\n }\n\n private createInst () {\n // 去除原本的实例\n this.disconnect()\n\n const { left = 0, top = 0, bottom = 0, right = 0 } = this._rootMargin\n return new IntersectionObserver(entries => {\n entries.forEach(entry => {\n const _callback = this._getCallbackByElement(entry.target)\n const result = {\n boundingClientRect: entry.boundingClientRect,\n intersectionRatio: entry.intersectionRatio,\n intersectionRect: entry.intersectionRect,\n relativeRect: entry.rootBounds || { left: 0, right: 0, top: 0, bottom: 0 },\n time: entry.time\n }\n // web端会默认首次触发\n if (!this._isInited && this._options.initialRatio <= Math.min.apply(Math, this._options.thresholds)) {\n // 初始的相交比例,如果调用时检测到的相交比例与这个值不相等且达到阈值,则会触发一次监听器的回调函数。\n return\n }\n _callback && _callback.call(this, result)\n })\n this._isInited = true\n }, {\n root: this._root,\n rootMargin: [`${top}px`, `${right}px`, `${bottom}px`, `${left}px`].join(' '),\n threshold: this._options.thresholds\n })\n }\n\n public disconnect (): void {\n if (this._observerInst) {\n let listener\n while ((listener = this._listeners.pop())) {\n this._observerInst.unobserve(listener.element)\n }\n this._observerInst.disconnect()\n }\n }\n\n public observe (targetSelector: string, callback: Taro.IntersectionObserver.ObserveCallback): void {\n // 同wx小程序效果一致,每个实例监听一个Selector\n if (this._listeners.length) return\n // 监听前没有设置关联的节点\n if (!this._observerInst) {\n console.warn('Intersection observer will be ignored because no relative nodes are found.')\n return\n }\n \n const nodeList = this._options.observeAll \n ? this.container.querySelectorAll(targetSelector) \n : [this.container.querySelector(targetSelector)]\n \n nodeList.forEach(element => {\n if (!element) return\n this._observerInst.observe(element)\n this._listeners.push({ element, callback })\n })\n }\n\n public relativeTo (selector: string, margins?: Taro.IntersectionObserver.RelativeToMargins | undefined): Taro.IntersectionObserver {\n // 已设置observe监听后,重新关联节点\n if (this._listeners.length) {\n console.error('Relative nodes cannot be added after \"observe\" call in IntersectionObserver')\n return this\n }\n this._root = this.container.querySelector(selector) || null\n if (margins) {\n this._rootMargin = margins\n }\n this._observerInst = this.createInst()\n return this\n }\n\n public relativeToViewport (margins?: Taro.IntersectionObserver.RelativeToViewportMargins | undefined): Taro.IntersectionObserver {\n return this.relativeTo('.taro_page', margins)\n }\n\n private _getCallbackByElement (element: Element) {\n const listener = this._listeners.find(listener => listener.element === element)\n return listener ? listener.callback : null\n }\n\n}\n"],"names":[],"mappings":";;AAGA;AACA,OAAO,uBAAuB,CAAC,CAAA;MASlB,0BAA0B,CAAA;IAgCrC,WAAa,CAAA,SAAiC,EAAE,OAAA,GAAkD,EAAE,EAAA;;AA3B5F,QAAA,IAAA,CAAA,QAAQ,GAAG;YACjB,UAAU,EAAE,CAAC,CAAC,CAAC;AACf,YAAA,YAAY,EAAE,CAAC;AACf,YAAA,UAAU,EAAE,KAAK;SAClB,CAAA;;QAKO,IAAU,CAAA,UAAA,GAAgB,EAAE,CAAA;;QAI5B,IAAW,CAAA,WAAA,GAAwD,EAAE,CAAA;;QAErE,IAAS,CAAA,SAAA,GAAG,KAAK,CAAA;AAavB,QAAA,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;QAC3B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;KACt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M;AACpB,YAAA,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;YACnC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAA;AAC7C,SAAC,CAAC,CAAA;KACH;IAEM,UAAU,CAAE,QAAgB,EAAE,OAAiE,EAAA;;AAEpG,QAAA,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;AAC1B,YAAA,OAAO,CAAC,KAAK,CAAC,6EAA6E,CAAC,CAAA;AAC5F,YAAA,OAAO,IAAI,CAAA;AACZ,SAAA;AACD,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAA;AAC3D,QAAA,IAAI,OAAO,EAAE;AACX,YAAA,IAAI,CAAC,WAAW,GAAG,OAAO,CAAA;AAC3B,SAAA;AACD,QAAA,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;AACtC,QAAA,OAAO,IAAI,CAAA;KACZ;AAEM,IAAA,kBAAkB,CAAE,OAAyE,EAAA;QAClG,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;KAC9C;AAEO,IAAA,qBAAqB,CAAE,OAAgB,EAAA;AAC7C,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAO,KAAK,OAAO,CAAC,CAAA;QAC/E,OAAO,QAAQ,GAAG,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAA;KAC3C;AAEF;;;;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -5125,13 +5125,6 @@ const createWorker = temporarilyNotSupport('createWorker');
|
|
|
5125
5125
|
// pollify
|
|
5126
5126
|
Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('intersection-observer')); });
|
|
5127
5127
|
class TaroH5IntersectionObserver {
|
|
5128
|
-
// selector 的容器节点
|
|
5129
|
-
get container() {
|
|
5130
|
-
const container = (this._component !== null
|
|
5131
|
-
? (findDOM(this._component) || document)
|
|
5132
|
-
: document);
|
|
5133
|
-
return container;
|
|
5134
|
-
}
|
|
5135
5128
|
constructor(component, options = {}) {
|
|
5136
5129
|
// 选项
|
|
5137
5130
|
this._options = {
|
|
@@ -5148,6 +5141,13 @@ class TaroH5IntersectionObserver {
|
|
|
5148
5141
|
this._component = component;
|
|
5149
5142
|
Object.assign(this._options, options);
|
|
5150
5143
|
}
|
|
5144
|
+
// selector 的容器节点
|
|
5145
|
+
get container() {
|
|
5146
|
+
const container = (this._component !== null
|
|
5147
|
+
? (findDOM(this._component) || document)
|
|
5148
|
+
: document);
|
|
5149
|
+
return container;
|
|
5150
|
+
}
|
|
5151
5151
|
createInst() {
|
|
5152
5152
|
// 去除原本的实例
|
|
5153
5153
|
this.disconnect();
|