glass-easel-miniprogram-adapter 0.13.0 → 0.14.0
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/glass_easel_miniprogram_adapter.d.ts +5 -5
- package/dist/glass_easel_miniprogram_adapter.es.js +1 -1
- package/dist/glass_easel_miniprogram_adapter.es.js.map +1 -1
- package/dist/glass_easel_miniprogram_adapter.js +1 -1
- package/dist/glass_easel_miniprogram_adapter.js.map +1 -1
- package/package.json +4 -4
- package/src/component.ts +2 -2
- package/src/intersection.ts +12 -5
package/src/intersection.ts
CHANGED
|
@@ -2,12 +2,19 @@ import type * as glassEasel from 'glass-easel'
|
|
|
2
2
|
import { type GeneralComponent } from './component'
|
|
3
3
|
|
|
4
4
|
export type IntersectionObserverMargins = {
|
|
5
|
-
left
|
|
6
|
-
top
|
|
7
|
-
right
|
|
8
|
-
bottom
|
|
5
|
+
left?: number
|
|
6
|
+
top?: number
|
|
7
|
+
right?: number
|
|
8
|
+
bottom?: number
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
const normalizeMarginRect = (margins: IntersectionObserverMargins) => ({
|
|
12
|
+
left: margins.left || 0,
|
|
13
|
+
top: margins.top || 0,
|
|
14
|
+
right: margins.right || 0,
|
|
15
|
+
bottom: margins.bottom || 0,
|
|
16
|
+
})
|
|
17
|
+
|
|
11
18
|
const defaultMargins = {
|
|
12
19
|
left: 0,
|
|
13
20
|
top: 0,
|
|
@@ -81,7 +88,7 @@ export class IntersectionObserver {
|
|
|
81
88
|
if (!this._$margins) {
|
|
82
89
|
throw new Error('`relativeTo` or `relativeToViewport` should be called before observe')
|
|
83
90
|
}
|
|
84
|
-
const { left, top, right, bottom } = this._$margins
|
|
91
|
+
const { left, top, right, bottom } = normalizeMarginRect(this._$margins)
|
|
85
92
|
const margin = `${top}px ${right}px ${bottom}px ${left}px`
|
|
86
93
|
targets.forEach((target) => {
|
|
87
94
|
let initial: number | null = this._$initialRatio
|