spritespin
spritespin copied to clipboard
resize eventListener not bind to window
I am currently using VERSION = "5.0.0-beta.1" and I noticed that listening on 'resize' doesn't work in my registered plugin.
It starts on line 1606:
var _loop_2 = function (key) {
if (typeof plugin[key] !== 'function') {
return "continue";
}
var listener = function (e) { return plugin[key].call(plugin, e, instance.state); };
destroy.addEventListener(instance.target, key, listener, { passive: false });
};
I tried this, and it works:
var _loop_2 = function (key) {
if (typeof plugin[key] !== 'function') {
return "continue";
}
var listener = function (e) { return plugin[key].call(plugin, e, instance.state); };
if (key === 'resize') {
window.addEventListener(key, listener, { passive: false });
} else {
destroy.addEventListener(instance.target, key, listener, { passive: false });
}
};
Could you please fix this ? I need to listen on window 'resize' because it breaks my plugin. Thanks in advance !
yes, resize
event is only triggered by the window
object and not the html element. As it is for now there is no DSL to tell spritespin what target object (window
or document
) it should attach its instance methods to. Everything is attached to the host element. I aggree that it would be quite handy to have that feature, but as i am not actively working on this project you must go around this by using the lifecycle events onInit
and onDestroy
to add and remove listeners at the window
object.