aboutsummaryrefslogtreecommitdiffstats
path: root/bower_components/bootstrap/js/affix.js
diff options
context:
space:
mode:
Diffstat (limited to 'bower_components/bootstrap/js/affix.js')
-rw-r--r--bower_components/bootstrap/js/affix.js33
1 files changed, 19 insertions, 14 deletions
diff --git a/bower_components/bootstrap/js/affix.js b/bower_components/bootstrap/js/affix.js
index 05c909e..7d404eb 100644
--- a/bower_components/bootstrap/js/affix.js
+++ b/bower_components/bootstrap/js/affix.js
@@ -1,5 +1,5 @@
/* ========================================================================
- * Bootstrap: affix.js v3.1.1
+ * Bootstrap: affix.js v3.2.0
* http://getbootstrap.com/javascript/#affix
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
@@ -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.2.0'
+
+ 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,14 +53,12 @@
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
var offsetBottom = offset.bottom
- if (this.affixed == 'top') position.top += scrollTop
-
if (typeof offset != 'object') offsetBottom = offsetTop = offset
if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
@@ -66,7 +68,7 @@
offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
if (this.affixed === affix) return
- if (this.unpin) this.$element.css('top', '')
+ if (this.unpin != null) this.$element.css('top', '')
var affixType = 'affix' + (affix ? '-' + affix : '')
var e = $.Event(affixType + '.bs.affix')
@@ -84,7 +86,9 @@
.trigger($.Event(affixType.replace('affix', 'affixed')))
if (affix == 'bottom') {
- this.$element.offset({ top: scrollHeight - offsetBottom - this.$element.height() })
+ this.$element.offset({
+ top: scrollHeight - this.$element.height() - offsetBottom
+ })
}
}
@@ -92,9 +96,7 @@
// AFFIX PLUGIN DEFINITION
// =======================
- var old = $.fn.affix
-
- $.fn.affix = function (option) {
+ function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.affix')
@@ -105,6 +107,9 @@
})
}
+ var old = $.fn.affix
+
+ $.fn.affix = Plugin
$.fn.affix.Constructor = Affix
@@ -130,7 +135,7 @@
if (data.offsetBottom) data.offset.bottom = data.offsetBottom
if (data.offsetTop) data.offset.top = data.offsetTop
- $spy.affix(data)
+ Plugin.call($spy, data)
})
})