Archived topic
Mobile Menu not working
37 replies · Started by David on November 19, 2020
Yes, I found the culprit. I have an element named:
JS: Passive Event Listeners
That is conflicting. When I turn this to Draft the menus work fine.
Here is the script that conflicts with the menus:
<script>
(function() {
var supportsPassive = eventListenerOptionsSupported();
if (supportsPassive) {
var addEvent = EventTarget.prototype.addEventListener;
overwriteAddEvent(addEvent);
}
function overwriteAddEvent(superMethod) {
var defaultOptions = {
passive: true,
capture: false
};
EventTarget.prototype.addEventListener = function(type, listener, options) {
var usesListenerOptions = typeof options === 'object';
var useCapture = usesListenerOptions ? options.capture : options;
options = usesListenerOptions ? options : {};
options.passive = options.passive !== undefined ? options.passive : defaultOptions.passive;
options.capture = useCapture !== undefined ? useCapture : defaultOptions.capture;
superMethod.call(this, type, listener, options);
};
}
function eventListenerOptionsSupported() {
var supported = false;
try {
var opts = Object.defineProperty({}, 'passive', {
get: function() {
supported = true;
}
});
window.addEventListener("test", null, opts);
} catch (e) {}
return supported;
}
})();
</script>
I'm not sure what the script is supposed to do.
Where did you get it from? Is it still needed?
and am I correct to assume that the other topic is resolved as well?
https://generatepress.com/forums/topic/primary-menu-not-working-right/
I'm sure it is the same issue. I added passive listeners because of this
I already know how GeneratePress works and already troubled shooted my plugins, but then I forget to look at the Elements and check them for conflicts. I am so sorry.
I don't think you need that snippet - it's never a good idea to add random snippets you found online without understanding how it works and the conflicts it could cause.
I'll close both topics now.
It is not a random script. It is useful if someone is trying to use Elementor Pro. I was seduced by Elementor Pro last week, but then came back to my senses. I know longer use it so I do not have a use for that script anymore. But it was not random.
Thank you for your time.
No problem :)