aboutsummaryrefslogtreecommitdiff
path: root/js/affix.js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2014-05-20 23:21:12 -0700
committerMark Otto <[email protected]>2014-05-20 23:21:12 -0700
commit91d51d3fba1cc2f80138bb2858ce67c28c9c8a89 (patch)
tree32fd8faabe6fdb8d17aea70fc7ccd56524d92aba /js/affix.js
parentc42cd8164c8698cbc3acfbb99e525bd8f195d819 (diff)
parent3dd1531d81c90d6d1cf04962032f868d315ab21c (diff)
downloadbootstrap-91d51d3fba1cc2f80138bb2858ce67c28c9c8a89.tar.xz
bootstrap-91d51d3fba1cc2f80138bb2858ce67c28c9c8a89.zip
Merge branch 'master' into icon_paths
Diffstat (limited to 'js/affix.js')
-rw-r--r--js/affix.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/js/affix.js b/js/affix.js
index 270b039bf..c7e1b797e 100644
--- a/js/affix.js
+++ b/js/affix.js
@@ -15,7 +15,8 @@
var Affix = function (element, options) {
this.options = $.extend({}, Affix.DEFAULTS, options)
- this.$window = $(window)
+
+ this.$target = $(this.options.target)
.on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
.on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
@@ -27,16 +28,19 @@
this.checkPosition()
}
- Affix.RESET = 'affix affix-top affix-bottom'
+ Affix.VERSION = '3.1.1'
+
+ Affix.RESET = 'affix affix-top affix-bottom'
Affix.DEFAULTS = {
- offset: 0
+ offset: 0,
+ target: window
}
Affix.prototype.getPinnedOffset = function () {
if (this.pinnedOffset) return this.pinnedOffset
this.$element.removeClass(Affix.RESET).addClass('affix')
- var scrollTop = this.$window.scrollTop()
+ var scrollTop = this.$target.scrollTop()
var position = this.$element.offset()
return (this.pinnedOffset = position.top - scrollTop)
}
@@ -49,7 +53,7 @@
if (!this.$element.is(':visible')) return
var scrollHeight = $(document).height()
- var scrollTop = this.$window.scrollTop()
+ var scrollTop = this.$target.scrollTop()
var position = this.$element.offset()
var offset = this.options.offset
var offsetTop = offset.top