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

slider position broken when dragging if scroll pane is not the same height as content #244

Closed
flexphperia opened this issue Jun 27, 2014 · 12 comments

Comments

@flexphperia
Copy link

When in CSS I've added top and bottom values into .nano-pane class to create scrollbar lower than content height then clicking and draging slider are broken.

Here's demo:
http://jsfiddle.net/eR34B/

@kristerkari
Copy link
Collaborator

thanks for reporting.

@kristerkari kristerkari added this to the 0.8.1 milestone Jun 30, 2014
@stereokai
Copy link

So... is this fixed? Thanks.

@kristerkari
Copy link
Collaborator

@stereokai Not yet. It would require so digging in the code to see why this happens.

@stereokai
Copy link

Ok thank you.

@erikhagreis
Copy link
Contributor

Hi, I just dove into the code as I wanted to achieve the same effect. I made a small change in the javascript code, the reset function at line 727 of jquery.nanoscroller.js. (corresponds with line 664 in the coffee file)

before:
sliderHeight = Math.round(paneOuterHeight / contentHeight * paneOuterHeight);

after:
sliderHeight = Math.round(paneOuterHeight / contentHeight * paneHeight);

I used the idea that the ratio windowHeight / contentHeight should equal sliderHeight / trackHeight.

The 'before' code has the assumption that the height of the scroll window (1st paneOuterHeight reference) is equal to the height of the track (2nd paneOuterHeight reference). This is the default case but in different styling, the trackHeight is actually equal to paneHeight.

At first glance this simple change did the trick. Can you verify?

@kristerkari
Copy link
Collaborator

@erikhagreis Thanks for helping out!

I tried to reproduce the problem with the JSFiddle from @flexphperia and nanoScroller 0.8.5, but it seemed to work just fine for me: https://jsfiddle.net/eR34B/3/

Is there something still broken with the scrolling/dragging? If there is, could you provide a demo of the broken functionality?

@erikhagreis
Copy link
Contributor

Yeah the issue only becomes apparent in some cases, where the contentHeight is only slightly greater than the trackHeight. I'll try to create a fiddle that demonstrates this.

@kristerkari
Copy link
Collaborator

@erikhagreis Thanks, that'd be great

@erikhagreis
Copy link
Contributor

This fiddle shows the error: https://jsfiddle.net/pgzeLxre/2/
In this fiddle the error seems fixed: https://jsfiddle.net/pgzeLxre/3/

@kristerkari
Copy link
Collaborator

Alright, looks like the fix works. I'll need to run the demo / your code in different browsers to see that it does not break anything else. 👍

@erikhagreis
Copy link
Contributor

thanks for checking :)

@kristerkari
Copy link
Collaborator

Should be fixed with release 0.8.6. Let's reopen if that is not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants