This repository was archived by the owner on May 7, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +45
-9
lines changed Expand file tree Collapse file tree 3 files changed +45
-9
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,22 @@ Include the javascript files at the bottom and you're good to go. No custom java
61
61
<script src =" src/ElementQueries.js" ></script >
62
62
```
63
63
64
+ ## Module Loader
65
+
66
+ If you're using a module loader you need to trigger the event listening or initialization yourself:
67
+
68
+ ``` javascript
69
+ var EQ = require (' node_modules/css-element-queries/ElementQueries' );
70
+
71
+ // attaches to DOMLoadContent
72
+ EQ .listen ();
73
+
74
+ // or if you want to trigger it yourself.
75
+ // Parse all available CSS and attach ResizeSensor to those elements which have rules attached
76
+ // (make sure this is called after 'load' event, because CSS files are not ready when domReady is fired.
77
+ EQ .init ();
78
+ ```
79
+
64
80
Issues
65
81
------
66
82
Original file line number Diff line number Diff line change 5
5
*/
6
6
;
7
7
( function ( ) {
8
+
9
+ var ResizeSensor = window . ResizeSensor ;
10
+
11
+ if ( typeof module !== 'undefined' && typeof module . exports !== 'undefined' ) {
12
+ ResizeSensor = require ( './ResizeSensor' ) ;
13
+ }
14
+
8
15
/**
9
16
*
10
17
* @type {Function }
350
357
else window . onload = callback ;
351
358
} ;
352
359
353
- if ( window . addEventListener ) {
354
- window . addEventListener ( 'load' , ElementQueries . init , false ) ;
355
- } else {
356
- window . attachEvent ( 'onload' , ElementQueries . init ) ;
357
- }
358
- domLoaded ( ElementQueries . init ) ;
360
+ ElementQueries . listen = function ( ) {
361
+ domLoaded ( ElementQueries . init ) ;
362
+ } ;
359
363
364
+ // make available to common module loader
365
+ if ( typeof module !== 'undefined' && typeof module . exports !== 'undefined' ) {
366
+ module . exports = ElementQueries ;
367
+ }
368
+ else {
369
+ window . ElementQueries = ElementQueries ;
370
+ ElementQueries . listen ( ) ;
371
+ }
360
372
} ) ( ) ;
Original file line number Diff line number Diff line change 14
14
*
15
15
* @constructor
16
16
*/
17
- this . ResizeSensor = function ( element , callback ) {
17
+ var ResizeSensor = function ( element , callback ) {
18
18
/**
19
19
*
20
20
* @constructor
120
120
changed ( ) ;
121
121
}
122
122
reset ( ) ;
123
- }
123
+ } ;
124
124
125
125
addEvent ( expand , 'scroll' , onScroll ) ;
126
126
addEvent ( shrink , 'scroll' , onScroll ) ;
155
155
} ;
156
156
} ;
157
157
158
- this . ResizeSensor . detach = function ( element ) {
158
+ ResizeSensor . detach = function ( element ) {
159
159
if ( element . resizeSensor ) {
160
160
element . removeChild ( element . resizeSensor ) ;
161
161
delete element . resizeSensor ;
162
162
delete element . resizedAttached ;
163
163
}
164
164
} ;
165
165
166
+ // make available to common module loader
167
+ if ( typeof module !== 'undefined' && typeof module . exports !== 'undefined' ) {
168
+ module . exports = ResizeSensor ;
169
+ }
170
+ else {
171
+ window . ResizeSensor = ResizeSensor ;
172
+ }
173
+
166
174
} ) ( ) ;
You can’t perform that action at this time.
0 commit comments