From 95734cf7cc2d84893873325cb7ffe054f99aff3e Mon Sep 17 00:00:00 2001 From: Guru Prasad Srinivasa Date: Wed, 1 Nov 2017 04:15:01 -0400 Subject: [PATCH] Allow setup event listeners to be set up as separate event listeners rather than in-conjunction with defaultListener This allows the setup listeners to do things like preventDefault()/stopImmediatePropagation() and have them work --- src/js/plyr.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/js/plyr.js b/src/js/plyr.js index 4da34153..4a708d32 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -472,13 +472,21 @@ // Bind along with custom handler function _proxyListener(element, eventName, userListener, defaultListener, useCapture) { + if(userListener) { + // Register this before defaultListener + _on( + element, + eventName, + function(event) { + userListener.apply(element, [event]); + }, + useCapture + ); + } _on( element, eventName, function(event) { - if (userListener) { - userListener.apply(element, [event]); - } defaultListener.apply(element, [event]); }, useCapture