0

I'm trying to synchronize the scrolling between two separate panels / divs.

One element has overflow: auto while the other has overflow: hidden (sort of trying to replicate a grid with frozen columns).

I can sync the scroll when the event happens within the element with overflow: auto but not the one with overflow: hidden (which is sort of normal if you ask me).

However, is there a workaround for this? I want to synchronize the scrolling both ways.

Here's a fiddle that will illustrate my issue (try scrolling in both panels): http://jsfiddle.net/0zzbkyqg/

Also, this thing seems to happen here already: http://demos.telerik.com/kendo-ui/grid/frozen-columns but I just can't understand how they're doing it.

2 Answers 2

2

Maybe you should make use of the wheel event which is triggered when you roll the mouse wheel, regardless of whether the section of the view has scrolled or not. Demo

$("#panel-left > table").on('wheel', function (e) { 
     // your logic here
}
Sign up to request clarification or add additional context in comments.

Comments

0

I'm thinking you don't need jQuery to do that.

Look here: http://jsfiddle.net/ty0jyr4y/

I've removed the position: absolute and overflow properties from the panels and added float: left to make them inline (could also use display: inline-block), and added height: 400px, width: 417px and overflow: auto to the container.

The container's width is set to 417px instead of 400px because the scroll bar takes 17 pixels of space (across all browsers according to here).

Works beautifully. Is this what you want?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.