Stickyflow
Scroll

Stickyflow is a plugin that enhance css sticky position by making it scroll the content also if overflowing the window.

Javascript

Import the javascript file with import 'xtendui/src/stickyflow'.

Initialize manually within javascript with new Xt.Stickyflow(document.querySelector('.my-container'), {/* options */}).

Usage

Be sure that sticky parent has not overflow-hidden or position: sticky; doesn't work.

Remember to use .items-stretch on on the container or .sticky doesn't work.

This addon is for css position: sticky; and doesn't need Gsap ScrollTrigger.

You can also set min and max value with top and bottom classes (e.g. top-[100px] bottom-[100px]) on self.element.

Options

Here are the main javascript options.

SyntaxDefault / ArgumentsDescription
Optiondebug:BooleanfalseDebug on console
Optionelement:QueryfalseSticky element query
Optionfiller:QueryfalseFiller element query
Optionscrollers:Query'.xt-overlay:not([data-xt-overlay-disabled])'Query for scroll nodes besides document (ordered parent > child)

Match Media

You can add additional options that gets added on match media query. You can use different queries with different and nested options.

SyntaxDefault / ArgumentsDescription
Optionmatches:ObjectfalseAdd additional options on match media query

Util

You can get self object on Xtend UI components with the constructor or Xt.get.

new Xt.Stickyflow(document.querySelector('.my-container'), {}).then(self => {})

// or

Xt.get({ name: 'xt-stickyflow', el: document.querySelector('.my-container') }).then(self => {})

You can set default options for all components of the same type, with Xt.options.

Xt.options['xt-stickyflow'] = {
  debug: true,
}

By default components are loaded and initialized only when inside viewport or instantly if self.container is not visible (display: none).

You can force global observer options or singular component observer options passing this option.

SyntaxDefault / ArgumentsDescription
Optionobserver:Boolean|nullnullForce enable or disable intersection observer

Listen

Listen to events, for listeners use this guideline.

SyntaxDOM ElementDescription
Eventchange.xt.stickyflowinputPosition change event
Eventsetup.xt.stickyflowcontainerSetup event
Eventinit.xt.stickyflowcontainerInit or reinit event
Eventstatus.xt.stickyflowcontainerStatus event (enabled or disabled)
Eventdestroy.xt.stickyflowcontainerDestroy event

Properties

Access properties by getting self object.

SyntaxDescription
Propertyself.componentName:StringComponent name (used in Xt.get)
Propertyself.options:ObjectFinal options
Propertyself.initial:BooleanIf initial or reset activation
Propertyself.disabled:BooleanIf component disabled
Propertyself.container:NodeContainer node
Propertyself.element:NodeSticky element
Propertyself.filler:NodesFiller element
Propertyself.scrollers:NodeAll scrolling element
Propertyself.scroller:NodeCurrent scrolling element

Methods

Call methods by getting self object.

SyntaxDescription
Methodself.reinit()Reinit component
Methodself.disable()Disable component
Methodself.enable()Enable component
Methodself.destroy()Destroy component