File tree 5 files changed +20
-0
lines changed
packages/monaco-enhance/src/browser
5 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 1
1
require ( './jest.setup.base' ) ;
2
2
require ( 'jest-canvas-mock' ) ;
3
+ require ( 'intersection-observer' ) ;
3
4
require ( 'jest-fetch-mock' ) . enableMocks ( ) ;
4
5
const { Buffer } = require ( 'buffer' ) ;
5
6
const timer = require ( 'timers' ) ;
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ global.getComputedStyle = jsdom.window.getComputedStyle;
42
42
global . window = jsdom . window ;
43
43
global . DOMParser = jsdom . window . DOMParser ;
44
44
global . MutationObserver = jsdom . window . MutationObserver ;
45
+ global . IntersectionObserver = jsdom . window . IntersectionObserver ;
45
46
global . KeyboardEvent = jsdom . window . KeyboardEvent ;
46
47
global . requestAnimationFrame = ( fn ) => setTimeout ( fn , 16 ) ;
47
48
global . cancelAnimationFrame = ( timer ) => {
Original file line number Diff line number Diff line change 107
107
"glob" : " ^8.0.1" ,
108
108
"handlebars" : " ^4.7.3" ,
109
109
"husky" : " ^7.0.4" ,
110
+ "intersection-observer" : " ^0.12.2" ,
110
111
"is-git-clean" : " ^1.1.0" ,
111
112
"jest" : " ^29.7.0" ,
112
113
"jest-canvas-mock" : " ^2.4.0" ,
Original file line number Diff line number Diff line change @@ -459,6 +459,13 @@ export abstract class ResizeZoneWidget extends ZoneWidget {
459
459
460
460
protected observeContainer ( dom : HTMLDivElement ) : IDisposable {
461
461
this . wrap = dom ;
462
+ const intersectionObserver = new IntersectionObserver ( ( entries ) => {
463
+ for ( const entry of entries ) {
464
+ if ( entry . isIntersecting ) {
465
+ this . resizeZoneWidget ( ) ;
466
+ }
467
+ }
468
+ } ) ;
462
469
const mutationObserver = new MutationObserver ( ( mutations ) => {
463
470
mutations . forEach ( ( mutation ) => {
464
471
if ( mutation . type === 'childList' ) {
@@ -482,9 +489,11 @@ export abstract class ResizeZoneWidget extends ZoneWidget {
482
489
} ) ;
483
490
this . resizeZoneWidget ( ) ;
484
491
} ) ;
492
+ intersectionObserver . observe ( this . wrap ) ;
485
493
mutationObserver . observe ( this . wrap , { childList : true , subtree : true } ) ;
486
494
return {
487
495
dispose ( ) {
496
+ intersectionObserver . disconnect ( ) ;
488
497
mutationObserver . disconnect ( ) ;
489
498
} ,
490
499
} ;
Original file line number Diff line number Diff line change @@ -1992,6 +1992,7 @@ __metadata:
1992
1992
glob: "npm:^8.0.1"
1993
1993
handlebars: "npm:^4.7.3"
1994
1994
husky: "npm:^7.0.4"
1995
+ intersection-observer: "npm:^0.12.2"
1995
1996
is-git-clean: "npm:^1.1.0"
1996
1997
jest: "npm:^29.7.0"
1997
1998
jest-canvas-mock: "npm:^2.4.0"
@@ -10904,6 +10905,13 @@ __metadata:
10904
10905
languageName: node
10905
10906
linkType: hard
10906
10907
10908
+ "intersection-observer@npm:^0.12.2":
10909
+ version: 0.12.2
10910
+ resolution: "intersection-observer@npm:0.12.2"
10911
+ checksum: 10/cb1a6369bd1636b3f227d7cb7fec22f5a35b9d8ba9e26303b405d50c54c3ef02c5a547107b1d951e7eb421e192a564222faf4660a21fad69c34dcb9f926c159c
10912
+ languageName: node
10913
+ linkType: hard
10914
+
10907
10915
"invariant@npm:^2.2.4":
10908
10916
version: 2.2.4
10909
10917
resolution: "invariant@npm:2.2.4"
You can’t perform that action at this time.
0 commit comments