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 })
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.
|
Method | Description |
---|---|
start |
Activate affix |
stop |
Deativate affix |
Inside each event function of affix element use@
orthis
in js. Class instance always stores in data attribute of the affix element@data['kitAffix']
orthis.data['kitAffix']
in js.
Event | Description |
---|---|
beforeactive |
Set a function to call it before start affix. If it returns 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. |