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

Scroll position on page reload - Latest version (3.5.4) #387

Closed
eugeniojauregui opened this issue Apr 23, 2014 · 17 comments
Closed

Scroll position on page reload - Latest version (3.5.4) #387

eugeniojauregui opened this issue Apr 23, 2014 · 17 comments

Comments

@eugeniojauregui
Copy link

I'm using the latest versión on a site who have body scroll and div scroll.
When a load the page both scrollbars appears in the correct position, but if I scroll the body a refresh the page, the div scroll shows in wrong position.
I try with the .resize() function but nothing happens:
$("body, .data-container").niceScroll({zindex: 9999, autohidemode: false });
$("body, .data-container").getNiceScroll().resize();
I'm using Chrome.
At last, I change the versión of nicescroll.js to 3.5.0, and works great.

First load
screen-nicescroll01

Page refresh at bottom
screen-nicescroll02

Thanks for the great job and the great plugin!

@andreuka
Copy link

line 603 of jquery.nicescroll.js
don`t know, if this right choice, but if chage this

this.getOffset = function() {
      if (self.isfixed) return {top:parseFloat(self.win.css('top')),left:parseFloat(self.win.css('left'))};
      if (!self.viewport) return self.win.offset();
      var ww = self.win.offset();
      var vp = self.viewport.offset();
      return {top:ww.top-vp.top+self.viewport.scrollTop(),left:ww.left-vp.left+self.viewport.scrollLeft()};
    };

to this

this.getOffset = function() {
      if (self.isfixed) return {top:parseFloat(self.win.css('top')),left:parseFloat(self.win.css('left'))};
      if (!self.viewport) return self.win.offset();
      var ww = self.win.offset();
      var vp = self.viewport.offset();
      return {top:ww.top-vp.top,left:ww.left-vp.left+self.viewport.scrollLeft()};
    };

all working fine

@Mephiztopheles
Copy link

fixed in newer version?

@smbeiragh
Copy link
Contributor

same issue #372 , same suggestion

@beckjonathan
Copy link

solution solved it for me too, thx

@smbeiragh
Copy link
Contributor

@inuyaksa, Please check this issue. this bug still exists in 3.5.6

@inuyaksa
Copy link
Owner

Sorry I can't reproduce, do you have a test page to watch?
I use Chrome 38 + Win7

@smbeiragh
Copy link
Contributor

387

on the main demo page
http://nicescroll.areaaperta.com/demo.html
1.open it.
2.Scroll down document
3.Reload page
4.and ... 🎯

it seems it adds the document scroll position in its calculations.
I'm on Ubuntu 12.04 with chrome 37 and chromium 37
chrome 37/38 on windows 8 is the same

@inuyaksa
Copy link
Owner

Thanks. Fixed on 3.5.8 BE, please try it
https://github.com/inuyaksa/jquery.nicescroll/tree/Bleeding-edge

@smbeiragh
Copy link
Contributor

Thank you, but it still exists.
I checked it via git.

git pull mainrepo
git checkout Bleeding-edge

inuyaksa added a commit that referenced this issue Oct 15, 2014
@inuyaksa
Copy link
Owner

New BE release, check it out

@smbeiragh
Copy link
Contributor

👍
It Works
Thank you!

@inuyaksa
Copy link
Owner

Good!

@rsurjano
Copy link

good solution, work! please update to stable version, thanks!

inuyaksa added a commit that referenced this issue Nov 10, 2014
List of fixes:
- scriptpath, Allows users to define their own "scriptpath" #309
- Rail positioning bug when hwacceleration is off in Chrome browser #447
- Scroll is Positioned at Page Bottom in Chrome. Nicescroll v 3.5.6 #443
- Uncaught TypeError: Cannot read property 'win' of null #439
- Multi-Touch gestures - OS X #431
- Nicescroll bar rail jumps after resize #425
- nicescroll rail positioned at the bottom in chrome when refreshing
page that has scroll #424
- CTRL-F not working do nicescroll #419
- IE 11 - touch support #418
- Multiple nicescroll containers can't use same config car? #409
- "*niceBar.locked = true" --- Unlocked by browser window resizing #408
- Scrollbar displayed but not scrollable on IE11 with Windows 8 touch
device #407
- this.getViewport doesn't check for relative #403
- Chrome Search on Windows breaks NiceScroll #400
- Vertical scrollbar problem in Chrome 35 when the scroll of the body is
greater than 0 #394
- Scroll position on page reload - Latest version (3.5.4) #387
- Incorrect scrollbar position after reload in Chrome #372
- Problem on expresion: /BODY|HTML/.test(dom.nodeName) #292
- Ctrl + mouse wheel - scrolling instead zooming in Firefox and IE #275
- Remove - Uncaught TypeError: Cannot set property 'onsync' of null #247
- JS Error in console: Uncaught TypeError: Cannot read property
'defaultView' of null  #245
- Touch support for W3C Pointer Events #420
- railpadding/railoffset fixed #413
- Fix for neverending drag mode on horizontal scrollbar disappear #371
- fixed 'use strict' errors #355
- Readability and maintainability improvement #336
- Update jquery.nicescroll.js #325
inuyaksa added a commit that referenced this issue Nov 21, 2014
New options
- scriptpath, Allows users to define their own "scriptpath" #309

Changed features
- Primitive bootstrap support - modal windows #449
- removed delayed method

Fixes
- Rail positioning bug when hwacceleration is off in Chrome browser #447
- Scroll is Positioned at Page Bottom in Chrome. Nicescroll v 3.5.6 #443
- Uncaught TypeError: Cannot read property 'win' of null #439
- Multi-Touch gestures - OS X #431
- Nicescroll bar rail jumps after resize #425
- nicescroll rail positioned at the bottom in chrome when refreshing
page that has scroll #424
- CTRL-F not working do nicescroll #419
- IE 11 - touch support #418
- Multiple nicescroll containers can't use same config car? #409
- "*niceBar.locked = true" --- Unlocked by browser window resizing #408
- Scrollbar displayed but not scrollable on IE11 with Windows 8 touch
device #407
- this.getViewport doesn't check for relative #403
- Chrome Search on Windows breaks NiceScroll #400
- Vertical scrollbar problem in Chrome 35 when the scroll of the body is
greater than 0 #394
- Scroll position on page reload - Latest version (3.5.4) #387
- Incorrect scrollbar position after reload in Chrome #372
- Problem on expresion: /BODY|HTML/.test(dom.nodeName) #292
- Ctrl + mouse wheel - scrolling instead zooming in Firefox and IE #275
- Remove - Uncaught TypeError: Cannot set property 'onsync' of null #247
- JS Error in console: Uncaught TypeError: Cannot read property
'defaultView' of null  #245
- railposition outside a fixed div in Chrome 38 and IE not correct #450
- Preserve Vertical scroll behavior after horizontal scrolling ends #451
- Wrapped divs, fix rail position for content already scrolled
- Detect content appends to page, refresh rail positions
- Nicescrolls are not located in the new positions #446
- Chrome, dragging cursor on touchbehavior losts mouse move
- cantouch capability is detected as a false positive in WebKitGTK+ #367
- Scrolling via touch not working on certain non-IOS webkit browsers
(namely Cisco's IEC 4600 series) #389
- Chrome, cursor drag on "touchbehavior"=TRUE
- IE10+ drag lock issue

Coding notes
- Initial code rewriting to detach legacy browser support for current
code

Thanks to contributors!!
- Touch support for W3C Pointer Events #420
- railpadding/railoffset fixed #413
- Fix for neverending drag mode on horizontal scrollbar disappear #371
- fixed 'use strict' errors #355
- Readability and maintainability improvement #336
- Update jquery.nicescroll.js #325
- cantouch capability is detected as a false positive in WebKitGTK+ #368
@babadofar
Copy link
Contributor

I have a related problem, where scrollbars appear at the wrong place on resize.
The issue is when putting scrollbars on a div, and scrolling the window down so that the top of the scrollable element lies above the visible area (negative position top). When I add new content to the scrollable div, and call resize, the wrong top posisiton is returned, so the scrollbar is now positioned above the element.
Uncommenting the addition of viewport.scrollTop() fixes this problem
https://github.com/inuyaksa/jquery.nicescroll/blob/master/jquery.nicescroll.js#L634

@IvoPereira
Copy link

@babadofar that fixed it for me either.

3.6.0 does not handles this problem currently.

@Avinash929
Copy link

It's resolve in newer version.

@chrisharrisonkiwi
Copy link

Still having trouble version: 3.6.8 with positioning when DOM updates, the horizontal position seems to take a few seconds before correcting itself.

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