iframe resize handler based takes too memory. Back to window.resize old school.
This commit is contained in:
parent
1a39d76e48
commit
4a988b5a21
@ -4,23 +4,11 @@ var update = require('./update');
|
|||||||
var instances = require('./instances');
|
var instances = require('./instances');
|
||||||
|
|
||||||
module.exports = function (element) {
|
module.exports = function (element) {
|
||||||
var CSS = 'position:absolute;left:0;top:-100%;width:100%;height:100%;margin:1px 0 0;border:none;opacity:0;visibility:hidden;pointer-events:none;';
|
|
||||||
|
|
||||||
var i = instances.get(element);
|
var i = instances.get(element);
|
||||||
|
|
||||||
var onMutationObserver = function () {
|
var onMutationObserver = function () {
|
||||||
update(element);
|
update(element);
|
||||||
};
|
};
|
||||||
|
|
||||||
var resizer = function (element, handler) {
|
i.event.bind(window, 'resize', onMutationObserver);
|
||||||
var frame = document.createElement('iframe');
|
|
||||||
frame.style.cssText = CSS;
|
|
||||||
element.appendChild(frame);
|
|
||||||
frame.onload = function () {
|
|
||||||
i.event.bind(frame.contentWindow, 'resize', handler);
|
|
||||||
};
|
|
||||||
return frame;
|
|
||||||
};
|
|
||||||
|
|
||||||
i.resizer = resizer(element, onMutationObserver);
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user