Lifetime updates on every purchase Support replies within 24 hours Secure checkout via Gumroad 8,500+ sales since 2016

Events

Updated 1 min read 2 views

Every callback receives a detail object:

{
  instance,  // SmoothBackground
  section,   // sections mode: the active section element
  index,     // current color index
  progress,  // scroll progress 0 – 1
  colors,    // rendered values, e.g. { 'background-color': 'rgb(212, 230, 106)' }
}
CallbackDOM eventWhen
onInitvlt-sbg:initInstance created.
onChangevlt-sbg:changeA new color is reached (loop), the nearest color changes (scroll), or a new section becomes active (sections).
onUpdate—Every rendered frame in scroll mode. Delivered only as a callback, for performance.
onCompletevlt-sbg:completeloop: all iterations are done.
onDestroyvlt-sbg:destroyInstance destroyed.

DOM events bubble, so you can listen on a parent:

document.body.addEventListener('vlt-sbg:change', (e) => {
  console.log(e.target, e.detail.index);
});
Was this article helpful?