I know this topic has been asked a lot here but I can't find anything recent and as far as I am aware the later jQuery versions do not support these functions anymore.
I have a website which scrolls horizontally, it works great but only when I swipe my trackpad sideways rather than scrolling vertically. Does anyone know of an updated way of doing this?
Can provide more code if needed. Just wondering if anyone knows a general way of tackling this.
Here is an example of what I am looking for (the first pink section before it scrolls down): https://alvarotrigo.com/fullPage/extensions/scroll-horizontally.html#firstPage/2
Here is a basic setup of what I have at the moment, it will only scroll if scrolled sideways rather than vertical and sideways. https://codepen.io/caitlinmooneyx/pen/WVrggB
Heres what I've tried so far:
How to Horizontal Scroll when scrolling vertical?
And:
var scroller = {};
scroller.e = document.getElementById("wrapper");
if (scroller.e.addEventListener) {
scroller.e.addEventListener("mousewheel", MouseWheelHandler, false);
scroller.e.addEventListener("DOMMouseScroll", MouseWheelHandler, false);
} else scroller.e.attachEvent("onmousewheel", MouseWheelHandler);
function MouseWheelHandler(e) {
// cross-browser wheel delta
var e = window.event || e;
var delta = -20 * (Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))));
var pst = $('#wrapper').scrollLeft() + delta;
if (pst < 0) {
pst = 0;
} else if (pst > $('.card').width()) {
pst = $('.card').width();
}
$('#wrapper').scrollLeft(pst);
return false;
};