tkahn / Smooth-Div-Scroll

A jQuery plugin for smooth scrolling. No longer maintained.
471 stars 184 forks source link

Uncaught TypeError: Cannot read property 'show' of undefined #195

Open kdon80 opened 9 years ago

kdon80 commented 9 years ago

I have ajax pages, when trying to leave the current page that has the scroll in it, it keeps throwing this message. Before leaving the page (rewriting using ajax), I even tried destroying the scroll. It successfully destroys but somehow the following event gets called:

_showHideHotSpots: function () {

the actual error happens here when calling show().

if (o.hotSpotScrolling && o.autoScrollingMode !== "always" && el.data("autoScrollingInterval") !== null) {
    el.data("scrollingHotSpotLeft").show();
    el.data("scrollingHotSpotRight").show();

I don't understand how this if statement passes since the scroll is already destroyed...

thanks,

kdon80 commented 9 years ago

The issue is in the window resize binding! After destroying it, window resize is still bound!

 (window).bind("resize", function () {
            self._showHideHotSpots();
kdon80 commented 9 years ago

You should this in the instruction: That when destroying the element, you might want to unbind the resize: $(window).off("resize");