File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -66,13 +66,26 @@ class Evented implements ResizeListener {
66
66
67
67
private onResize_ = ( entries : ResizeObserverEntry [ ] ) => {
68
68
for ( const entry of entries ) {
69
+ this . callback_ ( Evented . getResizeObserverEntrySize ( entry ) , entry . target ) ;
70
+ }
71
+ } ;
72
+
73
+ private static getResizeObserverEntrySize ( entry : ResizeObserverEntry ) : Vector2 {
74
+ if ( entry . borderBoxSize ) {
75
+ // Firefox implements borderBoxSize as an object instead of an array, so check for either
69
76
const borderBoxSize = entry . borderBoxSize as unknown ;
70
77
const borderBox : ResizeObserverSize = Array . isArray ( borderBoxSize )
71
78
? borderBoxSize [ 0 ] as ResizeObserverSize
72
79
: borderBoxSize as ResizeObserverSize ;
73
- this . callback_ ( { x : borderBox . inlineSize , y : borderBox . blockSize } , entry . target ) ;
80
+ return { x : borderBox . inlineSize , y : borderBox . blockSize } ;
81
+ } else if ( entry . contentRect ) {
82
+ // Safari doesn't return borderBoxSize, so fall back to contentRect
83
+ return { x : entry . contentRect . width , y : entry . contentRect . height } ;
74
84
}
75
- } ;
85
+
86
+ console . error ( 'failed to get size of ResizeObserverEntry' ) ;
87
+ return { x : 0 , y : 0 } ;
88
+ }
76
89
77
90
constructor ( callback : ResizeCallback ) {
78
91
this . callback_ = callback ;
You can’t perform that action at this time.
0 commit comments