You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ResizeObserver is available for the latest modern browsers for a while. Instead of inserting tricky DIV to catch "resize" event, it is better to simply use ResizeObserver.
For backward compability, I rewrite ResizeSensor with ResizeObserver (and Map) as an AMD module below. It works well for my project.
define(function() {
const observing = new Map(),
ro = new ResizeObserver(entries => {
for (let {target} of entries) {
(observing.get(target) || []).forEach(({callback}) => callback(target));
}
});
function ResizeSensor(elm, callback) {
observing.set(elm, [...observing.get(elm) || [], {callback, sensor: this]);
ro.observe(this.elm = elm);
}
ResizeSensor.prototype = {
constructor: ResizeSensor,
detach() {
let elm = this.elm;
ro.unobserve(elm);
observing.set(elm, [...observing.get(elm) || []].filter(({sensor}) => sensor !== this));
}
}
return ResizeSensor;
});
The text was updated successfully, but these errors were encountered:
ResizeObserver is available for the latest modern browsers for a while. Instead of inserting tricky DIV to catch "resize" event, it is better to simply use ResizeObserver.
For backward compability, I rewrite ResizeSensor with ResizeObserver (and Map) as an AMD module below. It works well for my project.
The text was updated successfully, but these errors were encountered: