mirror of https://github.com/IoTcat/ushio-img.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
4 years ago
|
// ==========================================================================
|
||
|
//
|
||
|
// Wheel
|
||
|
// Basic mouse weheel support for gallery navigation
|
||
|
//
|
||
|
// ==========================================================================
|
||
|
(function(document, $) {
|
||
|
"use strict";
|
||
|
|
||
|
var prevTime = new Date().getTime();
|
||
|
|
||
|
$(document).on({
|
||
|
"onInit.fb": function(e, instance, current) {
|
||
|
instance.$refs.stage.on("mousewheel DOMMouseScroll wheel MozMousePixelScroll", function(e) {
|
||
|
var current = instance.current,
|
||
|
currTime = new Date().getTime();
|
||
|
|
||
|
if (instance.group.length < 2 || current.opts.wheel === false || (current.opts.wheel === "auto" && current.type !== "image")) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
e.preventDefault();
|
||
|
e.stopPropagation();
|
||
|
|
||
|
if (current.$slide.hasClass("fancybox-animated")) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
e = e.originalEvent || e;
|
||
|
|
||
|
if (currTime - prevTime < 250) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
prevTime = currTime;
|
||
|
|
||
|
instance[(-e.deltaY || -e.deltaX || e.wheelDelta || -e.detail) < 0 ? "next" : "previous"]();
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
})(document, window.jQuery || jQuery);
|