Affix

The subnavigation on the right is a live demo of the affix plugin.

To move your affix block inside some parent, just add position: relative to that parent.
document.querySelector("#affix-el").affix({ offset: -25 })

Properties

Name Default Description
spy @el.getAttribute('data-spy') or 'affix' Set type of spying
offset @el.getAttribute( 'data-offset' ) or 5 In px. Affix's block offset from top.

Methods

Method Description
start

Activate affix

stop

Deativate affix

Events

Inside each event function of affix element use @ or this in js. Class instance always stores in data attribute of the affix element @data['kitAffix'] or this.data['kitAffix'] in js.
Event Description
beforeactive

Set a function to call it before start affix. If it returns deferred.promise(), then affix will not start till deferred.resolve(), and woun't start at all if deferred.reject(). You can just get data with ajax for your affix block.

el.affix
	beforeactive: ->
		d = $.Deferred()

		console.log @
		# The affix DOM element will be in the log

		console.log @data['kitAffix']
		# The instance of Affix class will in log

		# Do something here before start affix
		# in this case it will start after 2 seconds
		setTimeout ->
			d.resolve()
		, 2000
		# End of your code

		d.promise()

onactive

Set a function to call it after affix started.

failactive

Set a function to call it if starting failed.

beforedeactive

Call this function before affix stopped.

ondeactive

Call this function after affix stopped.

faildeactive

Set a function to call it if stopping failed.