All Projects → lucafalasco → Scroll Snap

lucafalasco / Scroll Snap

Licence: mit
↯ Snap page when user stops scrolling, with a customizable configuration and a consistent cross browser behaviour

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Scroll Snap

Horizontal Scroll
Horizontal scroll with inertia
Stars: ✭ 175 (-6.42%)
Mutual labels:  scroll, scrolling
Pd Select
vue components ,like ios 3D picker style,vue 3d 选择器组件,3D滚轮
Stars: ✭ 101 (-45.99%)
Mutual labels:  scroll, scrolling
Scroll Snap Carousel
Carousel based on CSS Scroll Snap functionality
Stars: ✭ 31 (-83.42%)
Mutual labels:  scroll, snap
Snappyrecyclerview
An extension to RecyclerView which will snap to child Views to the specified anchor, START, CENTER or END.
Stars: ✭ 178 (-4.81%)
Mutual labels:  scroll, snap
Scroll Js
Light cross-browser scroller that uses native javascript
Stars: ✭ 179 (-4.28%)
Mutual labels:  scroll, scrolling
Android scroll endless
Scroll endless for Android recyclerview
Stars: ✭ 12 (-93.58%)
Mutual labels:  scroll, scrolling
Ngx Ui Scroll
Infinite/virtual scroll for Angular
Stars: ✭ 145 (-22.46%)
Mutual labels:  scroll, scrolling
Scrolldir
0 dependency JS plugin to leverage scroll direction with CSS ⬆⬇ 🔌💉
Stars: ✭ 679 (+263.1%)
Mutual labels:  scroll, scrolling
Multiscroll.js
multiscroll plugin by Alvaro Trigo. Create scrolling split websites. http://alvarotrigo.com/multiScroll/
Stars: ✭ 1,537 (+721.93%)
Mutual labels:  scrolling, snap
Jquery Scrolllock
Locks mouse wheel scroll inside container, preventing it from propagating to parent element
Stars: ✭ 109 (-41.71%)
Mutual labels:  scroll, scrolling
Fuckmyscroll.js
🔮 Animated scrolling to certain point or anchor
Stars: ✭ 10 (-94.65%)
Mutual labels:  scroll, scrolling
Angular Fullpage
Official Angular wrapper for fullPage.js https://alvarotrigo.com/angular-fullpage/
Stars: ✭ 131 (-29.95%)
Mutual labels:  scrolling, snap
Txscrolllabelview
🌭TXScrollLabelView, the best way to show & display information such as adverts / boardcast / onsale e.g. with a customView.
Stars: ✭ 714 (+281.82%)
Mutual labels:  scroll, scrolling
Fullpage.js
fullPage plugin by Alvaro Trigo. Create full screen pages fast and simple
Stars: ✭ 32,974 (+17533.16%)
Mutual labels:  scrolling, snap
React Fullpage
Official React.js wrapper for fullPage.js https://alvarotrigo.com/react-fullpage/
Stars: ✭ 707 (+278.07%)
Mutual labels:  scrolling, snap
Dragscroll
micro library for drag-n-drop scrolling style
Stars: ✭ 989 (+428.88%)
Mutual labels:  scroll, scrolling
Pagepiling.js
pagePiling plugin by Alvaro Trigo. Create a scrolling pile of sections. http://alvarotrigo.com/pagePiling/
Stars: ✭ 3,993 (+2035.29%)
Mutual labels:  scrolling, snap
Recyclerview Fastscroller
A fully customizable Fast Scroller for the RecyclerView in Android, written in Kotlin
Stars: ✭ 585 (+212.83%)
Mutual labels:  scroll, scrolling
Prognroll
A tiny, lightweight jQuery plugin that creates scroll progress bar on the page.
Stars: ✭ 108 (-42.25%)
Mutual labels:  scroll, scrolling
Vue Fullpage.js
Official Vue.js wrapper for fullPage.js http://alvarotrigo.com/vue-fullpage/
Stars: ✭ 1,626 (+769.52%)
Mutual labels:  scrolling, snap

scroll-snap


npm npm npm downloads

Snap page when user stops scrolling, basically implements CSS Scroll Snap, adding a customizable configuration and a consistent cross browser behaviour.

  • works in all modern browsers
  • requestAnimationFrame for 60fps
  • customizable configuration (including easing functions)
  • no additional dependencies
  • no extra stylesheet

Installation

yarn add scroll-snap

You can also grab a pre-built version from unpkg

Usage

Call the constructor passing a DOM element and a configuration object as parameters, then use:

bind() to initialize the scroll snap and attach the scroll event listener, takes an optional callback as parameter to execute once the animation ends.

unbind() to remove the listener on the element.

Check out the following code:

import ScrollSnap from 'scroll-snap'

const snapConfig = {
  /**
   * snap-destination for x and y axes
   * should be a valid css value expressed as px|%|vw|vh
   */
  snapDestinationX: '0%',
  snapDestinationY: '90%',
  /**
   * time in ms after which scrolling is considered finished
   * [default: 100]
   */
  timeout: 100,
  /**
   * duration in ms for the smooth snap
   * [default: 300]
   */
  duration: 300,
  /**
   * threshold to reach before scrolling to next/prev element, expressed as a percentage in the range [0, 1]
   * [default: 0.2]
   */
  threshold: 0.2,
  /**
   * when true, the scroll container is not allowed to "pass over" the other snap positions
   * [default: false]
   */
  snapStop: false,
  /**
   * custom easing function
   * [default: easeInOutQuad]
   * for reference: https://gist.github.com/gre/1650294
   * @param t normalized time typically in the range [0, 1]
   */
  easing: easeInOutQuad,
}

function callback() {
  console.log('element snapped')
}

const element = document.getElementById('container')
const snapObject = new ScrollSnap(element, snapConfig)

snapObject.bind(callback)

// unbind the element
// snapObject.unbind();

Docs

Usage with React

Contributing

git clone https://github.com/lucafalasco/scroll-snap.git
cd scroll-snap
yarn install

Start the test app from docs/:

yarn start

Build lib for production:

yarn build

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].