mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-25 21:09:06 +02:00
fixes #11720 - Add events trigger to affix
This commit is contained in:
12
js/affix.js
12
js/affix.js
@@ -67,10 +67,20 @@
|
||||
if (this.affixed === affix) return
|
||||
if (this.unpin) this.$element.css('top', '')
|
||||
|
||||
var affixType = 'affix' + (affix ? '-' + affix : '')
|
||||
var e = $.Event(affixType + '.bs.affix')
|
||||
|
||||
this.$element.trigger(e)
|
||||
|
||||
if (e.isDefaultPrevented()) return
|
||||
|
||||
this.affixed = affix
|
||||
this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
|
||||
|
||||
this.$element.removeClass(Affix.RESET).addClass('affix' + (affix ? '-' + affix : ''))
|
||||
this.$element
|
||||
.removeClass(Affix.RESET)
|
||||
.addClass(affixType)
|
||||
.trigger($.Event(affixType.replace('affix', 'affixed')))
|
||||
|
||||
if (affix == 'bottom') {
|
||||
this.$element.offset({ top: document.body.offsetHeight - offsetBottom - this.$element.height() })
|
||||
|
Reference in New Issue
Block a user