Skip to content

Repository files navigation

Slide scroll banner

Slide scroll

A library that modifies element properties as you scroll to achieve parallax motion

Demo

Features

  • Vanilla Typescript
  • Light & Responsive
  • Use in your projects or as learning material

Options

DescriptionType
elThe slides elementsHTMLElement
easing?The easing function (see easing.js)String
debug?Log out some valuesboolean
modifiers?See Modifier type belowModifier[]

Modifier

DescriptionType
selectorThe css selector for the element to modifyString
property?The css property to modify (e.g. width)String
start?The starting propertyNumber
end?The destination property valueNumber
unit?The property unit (e.g. px, %)String
callback?A callback function which receives two parameters, the html element, and the progress through the active slideFunction

Usage

e.g.

import"./main.scss";importSlideScrollfrom"./slide-scroll"import{Options}from"./interfaces";constslides=document.querySelectorAll<HTMLElement>(`.slides`);slides.forEach(el=>{constoptions: Options={
el,easing: "easeInOutCubic",modifiers: [{selector: ".line",property: "width",start: 0,end: 100,unit: "%"},{selector: ".box",property: "height",start: 0,end: 100,unit: "%"},{selector: ".progress",callback: function(el,progress){el.innerHTML=`${Math.ceil(progress)}%`}}]};constslides=newSlideScroll(options)slides.watch();})

About

A library that modifies element properties as you scroll to achieve parallax motion

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages