0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-26 23:54:23 +01:00

cleanup style

This commit is contained in:
fat 2014-07-21 22:31:56 -07:00
parent 724c4f526c
commit eff9b063da

View File

@ -42,29 +42,22 @@
var position = this.$element.offset() var position = this.$element.offset()
var targetHeight = this.$target.height() var targetHeight = this.$target.height()
if (offsetTop != null && this.affixed == 'top') return scrollTop >= offsetTop ? false : 'top' if (offsetTop != null && this.affixed == 'top') return scrollTop < offsetTop ? 'top' : false
if (this.affixed == 'bottom') { if (this.affixed == 'bottom') {
// Can be affixed to the top, use the unpin value if (offsetTop != null) return (scrollTop + this.unpin <= position.top) ? false : 'bottom'
if (offsetTop != null) {
return (scrollTop + this.unpin <= position.top) ? false : 'bottom'
// Can only ever be pinned or affixed to the bottom, ignore unpin value
} else {
return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom' return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom'
} }
} else {
var initializing = this.affixed == null var initializing = this.affixed == null
var colliderTop = initializing ? scrollTop : position.top var colliderTop = initializing ? scrollTop : position.top
var colliderHeight = initializing ? targetHeight : height var colliderHeight = initializing ? targetHeight : height
if (offsetTop != null && colliderTop <= offsetTop) { if (offsetTop != null && colliderTop <= offsetTop) return 'top'
return 'top' if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom'
} else if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) {
return 'bottom'
} else {
return false return false
} }
}
}
Affix.prototype.getPinnedOffset = function () { Affix.prototype.getPinnedOffset = function () {
if (this.pinnedOffset) return this.pinnedOffset if (this.pinnedOffset) return this.pinnedOffset
@ -81,11 +74,11 @@
Affix.prototype.checkPosition = function () { Affix.prototype.checkPosition = function () {
if (!this.$element.is(':visible')) return if (!this.$element.is(':visible')) return
var scrollHeight = $('body').height()
var height = this.$element.height() var height = this.$element.height()
var offset = this.options.offset var offset = this.options.offset
var offsetTop = offset.top var offsetTop = offset.top
var offsetBottom = offset.bottom var offsetBottom = offset.bottom
var scrollHeight = $('body').height()
if (typeof offset != 'object') offsetBottom = offsetTop = offset if (typeof offset != 'object') offsetBottom = offsetTop = offset
if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element) if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)