File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
glass-easel-miniprogram-adapter/src Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -2,12 +2,19 @@ import type * as glassEasel from 'glass-easel'
22import { type GeneralComponent } from './component'
33
44export type IntersectionObserverMargins = {
5- left : number
6- top : number
7- right : number
8- bottom : number
5+ left ? : number
6+ top ? : number
7+ right ? : number
8+ bottom ? : number
99}
1010
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+
1118const defaultMargins = {
1219 left : 0 ,
1320 top : 0 ,
@@ -81,7 +88,7 @@ export class IntersectionObserver {
8188 if ( ! this . _$margins ) {
8289 throw new Error ( '`relativeTo` or `relativeToViewport` should be called before observe' )
8390 }
84- const { left, top, right, bottom } = this . _$margins
91+ const { left, top, right, bottom } = normalizeMarginRect ( this . _$margins )
8592 const margin = `${ top } px ${ right } px ${ bottom } px ${ left } px`
8693 targets . forEach ( ( target ) => {
8794 let initial : number | null = this . _$initialRatio
You can’t perform that action at this time.
0 commit comments