Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3008 - scroll thumb correctly positioned when dragging #3009

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@bartlomn
Copy link

bartlomn commented Mar 12, 2019

As per title, fixing incorrect positioning of scroll thumb when dragging.

@@ -100,19 +100,25 @@ const Scrollbar = {
});
scrollbar.$el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](swiper.params.scrollbar.lockClass);
},
getPointerPosition(e) {

This comment has been minimized.

@bartlomn

bartlomn Mar 12, 2019

Author

Extracted into a method of scrollbar as it's being reused across other methods

@@ -131,6 +137,7 @@ const Scrollbar = {
const { scrollbar, $wrapperEl } = swiper;
const { $el, $dragEl } = scrollbar;
swiper.scrollbar.isTouched = true;
swiper.scrollbar.dragStartPos = scrollbar.getPointerPosition(e) - e.target.getBoundingClientRect()[swiper.isHorizontal() ? 'left' : 'top'];

This comment has been minimized.

@bartlomn

bartlomn Mar 12, 2019

Author

Calculate position of mouse down relative to scroll thumb. Pass to scrollBar.

let positionRatio;
positionRatio = ((pointerPosition) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top'] - (dragSize / 2)) / (trackSize - dragSize);
positionRatio = ((scrollbar.getPointerPosition(e)) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top'] - (dragStartPos)) / (trackSize - dragSize);

This comment has been minimized.

@bartlomn

bartlomn Mar 12, 2019

Author

Main change. Instead of centering the thumb we now drag it relative to initial mouse down position.

@bartlomn bartlomn force-pushed the bartlomn:bugfix/3008-fix-scrollbar branch from a4c0053 to 5d5ac6e Mar 18, 2019

@nolimits4web

This comment has been minimized.

Copy link
Owner

nolimits4web commented Mar 25, 2019

Hi! Can you please revert changes from dist/ folder files? Only src/ files can be changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.