From c0e3391061de2ccd0bacdab2a483d5694fe6dcfe Mon Sep 17 00:00:00 2001 From: Giboo Date: Wed, 3 Oct 2012 15:10:22 +0300 Subject: [PATCH] Update js/jquery.smoothDivScroll-1.3.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding beforeEndDistance option to the object, to trigger scrollerRightLimitSoon callback. --- js/jquery.smoothDivScroll-1.3.js | 48 +++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/js/jquery.smoothDivScroll-1.3.js b/js/jquery.smoothDivScroll-1.3.js index c8f3cdb..4523dfa 100644 --- a/js/jquery.smoothDivScroll-1.3.js +++ b/js/jquery.smoothDivScroll-1.3.js @@ -43,6 +43,7 @@ getContentOnLoad: {}, // Object countOnlyClass: "", // String startAtElementId: "", // String + beforeEndDistance : 200, // Pixels // Hotspot scrolling hotSpotScrolling: true, // Boolean @@ -124,14 +125,14 @@ // Put the right and left hot spot back into the scroller again // or create them if they where not present from the beginning. if (el.data("scrollingHotSpotRight").length === 0) { - el.prepend("
"); + el.prepend("
>
"); el.data("scrollingHotSpotRight", el.find("." + o.scrollingHotSpotRightClass)); } else { el.prepend(el.data("scrollingHotSpotRight")); } if (el.data("scrollingHotSpotLeft").length === 0) { - el.prepend("
"); + el.prepend("
<
"); el.data("scrollingHotSpotLeft", el.find("." + o.scrollingHotSpotLeftClass)); } else { el.prepend(el.data("scrollingHotSpotLeft")); @@ -159,6 +160,7 @@ el.data("enabled", true); el.data("scrollableAreaHeight", el.data("scrollableArea").height()); el.data("scrollerOffset", el.offset()); + el.data("initialAjaxContentLoaded", false); /***************************************** SET UP EVENTS FOR TOUCH SCROLLING @@ -564,7 +566,7 @@ el.data("scrollingHotSpotLeft").hide(); el.data("scrollingHotSpotRight").show(); // Callback - self._trigger("scrollerLeftLimitReached"); + self._trigger("scrollerLeftLimitReached"); // Clear interval clearInterval(el.data("leftScrollingInterval")); el.data("leftScrollingInterval", null); @@ -576,7 +578,7 @@ el.data("scrollingHotSpotLeft").show(); el.data("scrollingHotSpotRight").hide(); // Callback - self._trigger("scrollerRightLimitReached"); + self._trigger("scrollerRightLimitReached"); // Clear interval clearInterval(el.data("rightScrollingInterval")); el.data("rightScrollingInterval", null); @@ -587,6 +589,12 @@ el.data("scrollingHotSpotLeft").show(); el.data("scrollingHotSpotRight").show(); } + // callback if right end is allmost reached + if (el.data("scrollableAreaWidth") <= (el.data("scrollWrapper").innerWidth() + o.beforeEndDistance + el.data("scrollWrapper").scrollLeft())) { + // Callback + + self._trigger("scrollerRightLimitSoon"); + } } // If auto scrolling is set to always, there should be no hotspots else { @@ -857,7 +865,13 @@ } // Recalculate the total width of the elements inside the scrollable area - self.recalculateScrollableArea(); + // if it's not the initial AJAX content load. If so, it's taken care of + // in the $(window).load eventhandler + if (el.data("initialAjaxContentLoaded")) { + self.recalculateScrollableArea(); + } else { + el.data("initialAjaxContentLoaded", true); + } // Determine which hotspots to show self._showHideHotSpots(); @@ -935,7 +949,13 @@ } // Recalculate the total width of the elements inside the scrollable area - self.recalculateScrollableArea(); + // if it's not the initial AJAX content load. If so, it's taken care of + // in the $(window).load eventhandler + if (el.data("initialAjaxContentLoaded")) { + self.recalculateScrollableArea(); + } else { + el.data("initialAjaxContentLoaded", true); + } // Determine which hotspots to show self._showHideHotSpots(); @@ -985,8 +1005,14 @@ } // Recalculate the total width of the elements inside the scrollable area - self.recalculateScrollableArea(); - + // if it's not the initial AJAX content load. If so, it's taken care of + // in the $(window).load eventhandler + if (el.data("initialAjaxContentLoaded")) { + self.recalculateScrollableArea(); + } else { + el.data("initialAjaxContentLoaded", true); + } + // Determine which hotspots to show self._showHideHotSpots(); @@ -1023,8 +1049,8 @@ el.data("scrollableArea").width(el.data("scrollableAreaWidth")); // Move to the starting position - el.data("scrollWrapper").scrollLeft(el.data("startingPosition")); - el.data("scrollXPos", el.data("startingPosition")); + //el.data("scrollWrapper").scrollLeft(el.data("startingPosition")); + //el.data("scrollXPos", el.data("startingPosition")); }, /********************************************************** Get current scrolling left offset @@ -1245,6 +1271,7 @@ // Set enabled to true el.data("enabled", true); + }, disable: function () { var self = this, el = this.element; @@ -1257,6 +1284,7 @@ // Set enabled to false el.data("enabled", false); + }, destroy: function () { var self = this, el = this.element;