aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey V. Zapparov <[email protected]>2013-09-02 03:24:27 +0200
committerAleksey V. Zapparov <[email protected]>2013-09-02 03:24:27 +0200
commit626cef9fa40a3759753383ff61d5ebde32bd9a18 (patch)
tree0795e5972fd97b33ca47448363146d7b2e49b55d
parent079fa16b9f067ea16995602d1da6f421ca31a191 (diff)
downloadbootstrap-626cef9fa40a3759753383ff61d5ebde32bd9a18.tar.xz
bootstrap-626cef9fa40a3759753383ff61d5ebde32bd9a18.zip
Pass $element to offset top/bottom calc funcs
At the moment to make dynamic top offset calculator on multiple elements, one would write: ``` javascript $('.my-affix').each(function () { var $el = $(this); $el.affix({ offset: { top: function () { return $el.offset().top; } } }); }) ``` This patch will allow to: ``` javascript $('.my-affix').affix({ offset: { top: function ($el) { return $el.offset().top; } } }); ```
-rw-r--r--js/affix.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/js/affix.js b/js/affix.js
index c7be96e1d..84760779d 100644
--- a/js/affix.js
+++ b/js/affix.js
@@ -57,8 +57,8 @@
var offsetBottom = offset.bottom
if (typeof offset != 'object') offsetBottom = offsetTop = offset
- if (typeof offsetTop == 'function') offsetTop = offset.top()
- if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
+ if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
+ if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :