Guys, I’ve composed a fix and can provide a patch. Will try posting here, but indentation will break most likely. Contact me via [email protected] if you want. Fix can be tested here
— D:/user/Documents/responsive-gallery-with-lightbox/lightbox/swipebox/jquery.swipebox.js Sat Oct 27 11:30:24 2018
+++ D:/user/Documents/jquery.swipebox.js Mon Oct 29 23:05:23 2018
@@ -52,6 +54,20 @@
return ui;
}
+ // This function checks if the specified event is supported by the browser.
+ // Source: https://perfectionkills.com/detecting-event-support-without-browser-sniffing/
+ function isEventSupported(eventName) {
+ var el = document.createElement(‘div’);
+ eventName = ‘on’ + eventName;
+ var isSupported = (eventName in el);
+ if (!isSupported) {
+ el.setAttribute(eventName, ‘return;’);
+ isSupported = typeof el[eventName] == ‘function’;
+ }
+ el = null;
+ return isSupported;
+ }
+
plugin.init = function() {
plugin.settings = $.extend( {}, defaults, options );
@@ -207,6 +223,7 @@
// Devices can have both touch and keyboard input so always allow key events
$this.keyboard();
+ $this.mouse();
$this.animBars();
$this.resize();
@@ -499,6 +516,34 @@
},
/**
+ * Mouse navigation
+ */
+ mouse : function () {
+ var wheelEvent = isEventSupported(‘mousewheel’) ? ‘mousewheel’ : ‘wheel’;
+ var $this = this;
+ $( window ).bind( wheelEvent, function( event ) {
+ event.preventDefault();
+ //event.stopPropagation();
+
+ var oEvent = event.originalEvent;
+ var delta = oEvent.deltaY || oEvent.wheelDelta;
+
+ // deltaY for wheel event
+ // wheelData for mousewheel event
+
+ console.log(delta);
+ if (delta > 0) {
+ // Scrolled up
+ $this.getNext();
+ } else if (delta < 0) {
+ // Scrolled down
+ $this.getPrev();
+ }
+
+ } );
+ },
+
+ /**
* Navigation events : go to next slide, go to prevous slide and close
*/
actions : function () {
@@ -759,6 +804,9 @@
*/
destroy : function () {
$( window ).unbind( ‘keyup’ );
+ // need to check which event to unbind the same way as having binded it
+ var wheelEvent = isEventSupported(‘mousewheel’) ? ‘mousewheel’ : ‘wheel’;
+ $( window ).unbind( wheelEvent );
$( ‘body’ ).unbind( ‘touchstart’ );
$( ‘body’ ).unbind( ‘touchmove’ );
$( ‘body’ ).unbind( ‘touchend’ );