File tree Expand file tree Collapse file tree 1 file changed +22
-15
lines changed
Expand file tree Collapse file tree 1 file changed +22
-15
lines changed Original file line number Diff line number Diff line change 1- ( function ( window ) {
1+ ( function ( window ) {
22 'use strict' ;
33
4- var getHandler = function ( eventName ) {
5- /**
6- * @param {Function } conditionCallback
7- * @param {Function } actionCallback
8- */
9- return function ( conditionCallback , actionCallback ) {
10- var ready = true ;
4+ /**
5+ * @template {'resize'|'scroll'} E
6+ *
7+ * @param {E } eventName
8+ *
9+ * @return {
10+ * (
11+ * condition: (this: Window) => boolean,
12+ * action: (this: Window, ready: boolean, event: GlobalEventHandlersEventMap[E]) => void
13+ * ) => void
14+ * }
15+ */
16+ function getHandler ( eventName ) {
17+ return function ( condition , action ) {
18+ let ready = true ;
1119
12- window . addEventListener ( eventName , function ( ) {
13- if ( conditionCallback . call ( this ) ) {
20+ window . addEventListener ( eventName , function ( event ) {
21+ if ( condition . call ( this ) ) {
1422 if ( ready ) {
15- actionCallback . call ( this , ready ) ;
23+ action . call ( this , ready , event ) ;
1624 ready = ! ready ;
1725 }
18- }
19- else {
26+ } else {
2027 if ( ! ready ) {
21- actionCallback . call ( this , ready ) ;
28+ action . call ( this , ready , event ) ;
2229 ready = ! ready ;
2330 }
2431 }
2532 } ) ;
2633 } ;
27- } ;
34+ }
2835
2936 window . conditionalBreakpoint = Object . create ( null ) ;
3037 window . conditionalBreakpoint . resize = getHandler ( 'resize' ) ;
You can’t perform that action at this time.
0 commit comments