Suppose I have this event handler:
var mousewheel = function (e) { };
But I want to debunk him. So I do this, which works as expected:
var mousewheelDebounced = _.debounce(mousewheel, 500);
$(document).on("mousewheel", function (e) {
e.preventDefault();
mousewheelDebounced(e);
}
But this does not work as expected:
$(document).on("mousewheel", function (e) {
e.preventDefault();
_.debounce(mousewheel, 500)(e);
}
I prefer the compactness of the second form. But there is no debugging.
I do not assume that the reference to mousewheelDebouncedremains, so each handler calls the calling handler. This is the reason? How can I clear this code if possible?
Here you can see the script .
h bob source
share