From 4fe0ae076060b27fddd2983f9ea416ff021a9ce7 Mon Sep 17 00:00:00 2001 From: jlukic Date: Mon, 2 Mar 2015 19:31:33 -0500 Subject: [PATCH] Add onUpdate callback to visibility, fix event handlers --- src/definitions/behaviors/visibility.js | 9 +++++++++ src/definitions/modules/sticky.js | 1 + 2 files changed, 10 insertions(+) diff --git a/src/definitions/behaviors/visibility.js b/src/definitions/behaviors/visibility.js index c19b96038..19ae42ffe 100644 --- a/src/definitions/behaviors/visibility.js +++ b/src/definitions/behaviors/visibility.js @@ -98,6 +98,8 @@ $.fn.visibility = function(parameters) { .off(eventNamespace) .removeData(moduleNamespace) ; + $window.off('resize' + eventNamespace, module.event.refresh); + $context.off('scroll' + eventNamespace, module.event.scroll); }, observeChanges: function() { @@ -313,6 +315,12 @@ $.fn.visibility = function(parameters) { module.bottomVisible(); module.topPassed(); module.bottomPassed(); + + // on update callback + if(settings.onUpdate) { + settings.onUpdate.call(element, module.get.elementCalculations()); + } + } }, @@ -1003,6 +1011,7 @@ $.fn.visibility.settings = { onBottomPassedReverse : false, // utility callbacks + onUpdate : false, // disabled by default for performance onRefresh : function(){}, onScroll : function(){}, diff --git a/src/definitions/modules/sticky.js b/src/definitions/modules/sticky.js index 5d3df6104..abfb3e435 100644 --- a/src/definitions/modules/sticky.js +++ b/src/definitions/modules/sticky.js @@ -743,6 +743,7 @@ $.fn.sticky.settings = { pushing : false, context : false, scrollContext : window, + offset : 0, bottomOffset : 0,