-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Uncaught TypeError: Cannot read property 'length' of undefined (if you enable scrollbars) #768
Comments
Yeah, this happens prior to execution of
And if we look at what triggers it:
It looks like this error raises when you have destroyed the iScroll object, but yet timer has not been cleared out. |
I have the same problem when destroying and re-initialising IScroll. However the code that's causing the problem for me is the resize function.
As far as I can tell that.refresh() tries to update the scrollbar indicators and because it has already been removed from the DOM and from the IScroll object, IScroll throws an error. A simple check on the below function fixes the problem
I think it's sensible to add the check, as I have seen on the other places IScroll does perform a check for the indicators. |
I can confirm that nim23's fix worked for me. |
Hello. I got the same error when it tries to continue scrolling on inertia after destroying iScroll. |
nim23's fix worked for me as well. |
In case if someone is facing this issue and don't want to modify the source code of the lib, you can do this before the destroy:
|
+1 Experienced the same issue when using iScroll with Knockout JS. |
@nim23 thank you. I merged on master branch. |
If I have hideScrollbar:false and scrollbars:true as an option and after a resize I reinitialise the iScroll (so I destroy it first and reinitialise it) with the same option I get this error if the scrollbars are true as soon as I switch this options to false the error doesn't happen but it does every time if I have the scrollbar options enabled as above.
The text was updated successfully, but these errors were encountered: