inuyaksa / jquery.nicescroll

nicescroll plugin for jquery - scrollbars like iphone/ipad
https://nicescroll.areaaperta.com/
3.6k stars 1.67k forks source link

IE 9 issue - Unable to get property 'rail' of undefined or null reference #697

Closed kumkanillam closed 2 years ago

kumkanillam commented 7 years ago

I am using v3.7.6. getting the below error in IE 9

Unable to get property 'rail' of undefined or null reference

It points to the below line.



            if (!self.rail.drag) return true;

            if (e.targetTouches && opt.preventmultitouchscrolling) {
              if (e.targetTouches.length > 1) return true; // multitouch
            }```
ak868308 commented 6 years ago

I have the same issue :(

But, @kumkanillam try the following hope it should work for you

When your div size or position has constantly changed because you use a dynamic layout, it’s better use a wrapped div.

In normal condition you can add nicescroll to a scrollable div. Nicescroll add custom scrollbar as absolute element of page (or main absolute container), actual DOM is very limited to detect element resize e repositioning so is possible to have a scrollbar position mismatch. You can resolve this issue using wrapper div, then scrollbar has absolute positioned about content div.

To create a wrapped div, you have do add a content div into main scrollable div, such as: <div class="nicescroll-box"> <div class="wrap"> your scrollable content </div></div>

Add nicescroll to wrapped div need an additional parameter to specify the wrapped div.

$(".nicescroll-box").niceScroll(".wrap",{cursorcolor:"aquamarine"});

nico-villalonga commented 5 years ago

Hi I know this is old, but we are using the library at work and I fix this problem with pr #796. If anyone come to this issue, you can download nicescroll (not minified) update changes and minify it to use. For minification you can use task runners or simply UglifyJS If you are looking for scrolling libraries take into account this is unmaintained.

kumkanillam commented 5 years ago

Now it's occurring for all the browsers with touch enabled. Thank you for the fix @nico-villalonga also please refer this ref #762 its clearly explaining the case.