Skip to content Skip to sidebar Skip to footer

Change Scroll Direction At Anchor Point

on my site I have 6 divs each div the same height and width of the browser window, so 5 are out of view, 3 left aligned then 3 more on top, as so.... When my visitors scroll, id l

Solution 1:

Check this out. It allows you to scroll in different directions and set up "slides" like above

http://joelb.me/scrollpath/

Solution 2:

Simple (maybe helpful) and not perfect:

var win = $(window),
    doc = $(document),
    bodyH = doc.height() - win.height(),
    page4 = $('#page4');

win.scrollTop(bodyH);


$(document).on('DOMMouseScroll mousewheel', function(e, delta) {
    delta = delta || -e.originalEvent.detail / 3 || e.originalEvent.wheelDelta / 120;

    if(delta < 0) {
        if(win.scrollLeft() > page4.offset().left && win.scrollTop() !== 0) {
            win.scrollTop(win.scrollTop() + delta * 30);
        } else {
            win.scrollLeft(win.scrollLeft() - delta * 30);
        }
    } else {
        if(win.scrollLeft() < page4.offset().left && (win.scrollTop() > 0 || win.scrollTop() === 0) && win.scrollTop() !== bodyH) {
            win.scrollTop(win.scrollTop() + delta * 30);
        } else {
            win.scrollLeft(win.scrollLeft() - delta * 30);
        }
    }

    e.preventDefault();
});

demo

Post a Comment for "Change Scroll Direction At Anchor Point"