Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions jquery.scrollify.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ if touchScroll is false - update index
firstLoad = true,
initialised = false,
destination = 0,
scrollOptions = false,
wheelEvent = 'onwheel' in document ? 'wheel' : document.onmousewheel !== undefined ? 'mousewheel' : 'DOMMouseScroll',
settings = {
//section should be an identifier that is the same for each section
Expand All @@ -91,6 +92,19 @@ if touchScroll is false - update index
afterResize:function() {},
afterRender:function() {}
};
// Some modern browsers requires passive to be set to be allow us to cancel events. We are performing
// Mozillas check to see if passive is an option, otherwise fall back to just setting capture to false.
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
try {
var options = Object.defineProperty({}, "passive", {
get: function () {
scrollOptions = {capture: false, passive: false};
}
});

window.addEventListener("test", null, options);
} catch (err) { }

function animateScroll(index,instant,callbacks,toTop) {
if(currentIndex===index) {
callbacks = false;
Expand Down Expand Up @@ -505,9 +519,9 @@ if touchScroll is false - update index
},
init: function() {
if (document.addEventListener && settings.touchScroll) {
document.addEventListener('touchstart', swipeScroll.touchHandler, false);
document.addEventListener('touchmove', swipeScroll.touchHandler, false);
document.addEventListener('touchend', swipeScroll.touchHandler, false);
document.addEventListener('touchstart', swipeScroll.touchHandler, scrollOptions);
document.addEventListener('touchmove', swipeScroll.touchHandler, scrollOptions);
document.addEventListener('touchend', swipeScroll.touchHandler, scrollOptions);
}
}
};
Expand Down Expand Up @@ -785,9 +799,9 @@ if touchScroll is false - update index
$window.off('keydown', manualScroll.keyHandler);

if (document.addEventListener && settings.touchScroll) {
document.removeEventListener('touchstart', swipeScroll.touchHandler, false);
document.removeEventListener('touchmove', swipeScroll.touchHandler, false);
document.removeEventListener('touchend', swipeScroll.touchHandler, false);
document.removeEventListener('touchstart', swipeScroll.touchHandler, scrollOptions);
document.removeEventListener('touchmove', swipeScroll.touchHandler, scrollOptions);
document.removeEventListener('touchend', swipeScroll.touchHandler, scrollOptions);
}
heights = [];
names = [];
Expand Down