1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-12 16:44:17 +02:00

fix affix…

This commit is contained in:
fat
2013-07-25 23:30:13 -07:00
parent 124d7e6279
commit f5f04ae4a0
5 changed files with 46 additions and 13 deletions

View File

@@ -36,6 +36,8 @@
this.checkPosition()
}
Affix.RESET = 'affix affix-top affix-bottom'
Affix.DEFAULTS = {
offset: 0
}
@@ -53,7 +55,6 @@
var offset = this.options.offset
var offsetTop = offset.top
var offsetBottom = offset.bottom
var reset = 'affix affix-top affix-bottom'
if (typeof offset != 'object') offsetBottom = offsetTop = offset
if (typeof offsetTop == 'function') offsetTop = offset.top()
@@ -64,11 +65,16 @@
offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
if (this.affixed === affix) return
if (this.unpin) this.$element.css('top', '')
this.affixed = affix
this.unpin = affix == 'bottom' ? position.top - scrollTop : null
this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
this.$element.removeClass(Affix.RESET).addClass('affix' + (affix ? '-' + affix : ''))
if (affix == 'bottom') {
this.$element.offset({ top: document.body.offsetHeight - offsetBottom - this.$element.height() })
}
}