iframe resize handler based takes too memory. Back to window.resize old school.

This commit is contained in:
nobuti 2017-01-12 09:25:17 +01:00
parent 1a39d76e48
commit 4a988b5a21

View File

@ -4,23 +4,11 @@ var update = require('./update');
var instances = require('./instances');
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 onMutationObserver = function () {
update(element);
};
var resizer = function (element, handler) {
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);
i.event.bind(window, 'resize', onMutationObserver);
};