How to implement scrolling element to the right/left when you reach the block?

Colleagues are welcome. The task is to implement the ability to scroll block right/left , provided that we have looked through the page to the desired block.

Here's a similar example

But there is an additional problem : if we scroll the page from top to bottom the unit slides should move in the opposite direction. Can't find property or method to prosquality the block to the right , because there is only property scrollLeft .How do you implement this task ? how to manage scrolling to the right ? I would be grateful for any help in this matter )
April 3rd 20 at 18:47
1 answer
April 3rd 20 at 18:49
// top-down
 if (scrollTop > targetOffset && sliderScrollLeft < sliderMaxScrollLeft) {
 $window.scrollTop(targetOffset + 1); // +1 because otherwise shaking when rewinding
 $slider.scrollLeft(sliderScrollLeft + horizontal_scrolling_speed);
 // bottom-up
 if (scrollTop < targetOffset && sliderScrollLeft > 0) {
 $window.scrollTop(targetOffset - 1);
 $slider.scrollLeft(sliderScrollLeft - horizontal_scrolling_speed);

All is well, but Mac users have its own flavor in the process. If touchpad to scroll the page all the rules and the block, which is a slider. The speed to scroll the page to the slider and inside the slider are different . It is not clear how to adjust the scrolling speed. ? It is possible to define the speed of scrolling pages and ask the same speed slider ?) I would be grateful for help ) - jerel.Ernser81 commented on April 3rd 20 at 18:52

Find more questions by tags JavaScriptjQueryHTMLLayoutWeb Development