Skip to content

Use UMD module definition for increase compatibility. #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/ElementQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
* https://github.com/marcj/css-element-queries/blob/master/LICENSE.
*/
;
(function() {

var ResizeSensor = window.ResizeSensor;

if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
ResizeSensor = require('./ResizeSensor');
(function (root, factory) {
if (typeof define === "function" && define.amd) {
define(['./ResizeSensor.js'], factory);
} else if (typeof exports === "object") {
module.exports = factory(require('./ResizeSensor.js'));
} else {
root.ElementQueries = factory(root.ResizeSensor);
}
}(this, function (ResizeSensor) {

/**
*
Expand Down Expand Up @@ -507,4 +509,7 @@
window.ElementQueries = ElementQueries;
ElementQueries.listen();
}
})();

return ElementQueries;

}));
20 changes: 11 additions & 9 deletions src/ResizeSensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
* https://github.com/marcj/css-element-queries/blob/master/LICENSE.
*/
;
(function() {
(function (root, factory) {
if (typeof define === "function" && define.amd) {
define(factory);
} else if (typeof exports === "object") {
module.exports = factory();
} else {
root.ResizeSensor = factory();
}
}(this, function () {

// Only used for the dirty checking, so the event callback count is limted to max 1 call per fps per sensor.
// In combination with the event based resize sensor this saves cpu time, because the sensor is too fast and
Expand Down Expand Up @@ -205,12 +213,6 @@
});
};

// make available to common module loader
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = ResizeSensor;
}
else {
window.ResizeSensor = ResizeSensor;
}
return ResizeSensor;

})();
}));