Sticky helps to keep handy elements on the page while scrolling. Handy for persistent navigation and advertising.
Sticky helps to keep handy elements on the page while scrolling. Handy for persistent navigation and advertising.
type: 'auto',
track: 'xy',
bufferLeft: 0,
bufferTop: 0,
bufferRight: 'width',
bufferBottom: 'height',
constrainTo: '',
oninit: function(){},
onscroll: function(){},
onscrolltopstart: function(){},
onscrolltopend: function(){},
onscrollleftstart: function(){},
onscrollleftend: function(){}
The type of sticking operation.
Default: auto
Which axes to track.
Default: xy
The space left of the element to start scrolling.
Default: 0
The space above the element to start scrolling.
Default: 0
The space right of the element to stop scrolling.
Default: 0
The space below element to stop scrolling.
Default: 0
The element to use as the boundary box for the stickied element. element
Default: undefined
Function to trigger when the element has been stickied.
Default: function(){}
Function to trigger when the $(window).scrollLeft() or $(window).scrollTop() is within the stickied element's scroll area.
Default: function(){}
Function to trigger when the element reaches its highest point within its scroll area on the Y axis.
Default: function(){}
Function to trigger when the element reaches its lowest point within its scroll area on the Y axis.
Default: function(){}
Function to trigger when the element reaches its highest point within its scroll area on the X axis.
Default: function(){}
Function to trigger when the element reaches its highest point within its scroll area on the X axis.
Default: function(){}
The object returned when triggering a sticky event.
{
elem: element,
scrollTop: $(window).scrollTop(),
scrollLeft: $(window).scrollLeft(),
scrollTopAmount: $(window).scrollTop()-$.data(element, 'scrollTop'),
scrollLeftAmount: $(window).scrollLeft()-$.data(element, 'scrollLeft')
}
Specific data about the stickied element is attached to it using the jQuery.data() or jQuery.fn.data() methods. This data can be both set and retrieved.
To view all the data attached to an element, use console.log( $.data(elem) );
Enable the debug output for stickied elements. Good idea to call this first before sticking any elements.
Default: 0
$.data(document, 'stickyDebug', 1);
The sticking type.
$.data(element, 'stickyType');
Track the X axis.
$.data(element, 'stickyTrackX');
Track the Y axis.
$.data(element, 'stickyTrackY');
The X co-ordinate start of the scroll area.
$.data(element, 'scrollLeft');
The Y co-ordinate start of the scroll area.
$.data(element, 'scrollTop');
The X co-ordinate end of the scroll area.
$.data(element, 'scrollRight');
The Y co-ordinate end of the scroll area.
$.data(element, 'scrollBottom');
The amount to offset the start of the scroll area on the X axis.
$.data(element, 'bufferLeft');
The amount to offset the start of the scroll area on the Y axis.
$.data(element, 'bufferTop');
The amount to offset the end of the scroll area on the X axis.
$.data(element, 'bufferRight');
The amount to offset the end of the scroll area on the Y axis.
$.data(element, 'bufferBottom');
The element to constrain the stickied element to.
NOTE: The scroll area is taken from this element so setting it to a different element after the initialisation won't change the stickied element's scroll area.
$.data(element, 'constrainTo');
The stickied element's original X start co-ordinate. This is relative to the parent/constrainTo element if position:relative or position:fixed, or relative to the document if parent/constrainTo element is position:absolute.
$.data(element, 'originLeft');
The stickied element's original Y start co-ordinate. This is relative to the parent/constrainTo element if position:relative or position:fixed, or relative to the document if parent/constrainTo element is position:absolute.
$.data(element, 'originTop');
The stickied element's original X end co-ordinate. This is relative to the parent/constrainTo element if position:relative or position:fixed, or relative to the document if parent/constrainTo element is position:absolute.
$.data(element, 'originRight');
The stickied element's original Y end co-ordinate. This is relative to the parent/constrainTo element if position:relative or position:fixed, or relative to the document if parent/constrainTo element is position:absolute.
$.data(element, 'originBottom');