开发者

Overriding scroll function within only one element

开发者 https://www.devze.com 2023-03-05 00:47 出处:网络
I\'m using jquery to provide clickable overlays, I\'d like to replace the default Scroll up/down methods with left/right (So when you scroll the page it moves horizontally not vertically. I\'m worried

I'm using jquery to provide clickable overlays, I'd like to replace the default Scroll up/down methods with left/right (So when you scroll the page it moves horizontally not vertically. I'm worried about the scroll function still working as intended within the overlays.

Update: If it's not possible to scroll th开发者_JAVA百科e browser what about a div that has a horizontal scroll bar that on scroll up/down moves left to right (as well as anchors)

My JavaScript experience is somewhat limited, any guidance with this matter would be greatly appreciated Thanks!


Found an appropriate solution with: http://plugins.jquery.com/project/ScrollTo my code:

function shiftScroll(offset) {
    console.log('current:' + window.pageXOffset);
    console.log('currentY:' + window.pageYOffset);
    $(window).scrollTo(window.pageXOffset + offset, window.pageYOffset, {axis:'x'});
}

I still need to disable the vertical scroll bars in the body, while not disabling the vertical scroll bars in elements within the page.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号