All Projects → baptistebriel → Smooth Scrolling

baptistebriel / Smooth Scrolling

Licence: mit
smooth scrolling and parallax effects on scroll

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Smooth Scrolling

Smooth Scrollbar
Customizable, Pluginable, and High-Performance JavaScript-Based Scrollbar Solution.
Stars: ✭ 2,695 (+424.32%)
Mutual labels:  scrollbar, smooth-scrolling
smooth-vuebar
Vue directive wrapper for smooth-scrollbar
Stars: ✭ 29 (-94.36%)
Mutual labels:  smooth-scrolling, scrollbar
Rolly
Custom scroll with inertia, smooth parallax and scenes manager
Stars: ✭ 109 (-78.79%)
Mutual labels:  parallax, smooth-scrolling
Locomotive Scroll
🛤 Detection of elements in viewport & smooth scrolling with parallax.
Stars: ✭ 4,231 (+723.15%)
Mutual labels:  parallax, smooth-scrolling
smooth-parallax
Smooth Parallax makes it a lot easier to move objects when the page scroll with ease.
Stars: ✭ 66 (-87.16%)
Mutual labels:  parallax, smooth-scrolling
Ngx Scrollbar
Custom overlay-scrollbars with native scrolling mechanism
Stars: ✭ 355 (-30.93%)
Mutual labels:  scrollbar, smooth-scrolling
Transformer page view
PageTransformer for flutter
Stars: ✭ 341 (-33.66%)
Mutual labels:  parallax
Parallaxbacklayout
无需改动原有activity只需要一个annotation轻松实现任意方向的滑动返回,默认提供微信滑动、跟随滑动、以及单个滑动,并且可以自定义滑动效果
Stars: ✭ 400 (-22.18%)
Mutual labels:  parallax
Quantum Nox Firefox Dark Full Theme
These usercontent and userchrome files will give a full themed dark color to Firefox Quantum, menus and dialogs included, as well as the scrollbars. You can also use the JS files to enable multirow tabs and other functions.
Stars: ✭ 328 (-36.19%)
Mutual labels:  scrollbar
Tilt.js
A tiny 60+fps parallax tilt hover effect for jQuery.
Stars: ✭ 3,442 (+569.65%)
Mutual labels:  parallax
Rnparallax
A react native scroll view component with Parallax header :p
Stars: ✭ 474 (-7.78%)
Mutual labels:  parallax
Immersivedetailsample
A sample application show how to realize immersive parallax effect header like Google Play Store
Stars: ✭ 457 (-11.09%)
Mutual labels:  parallax
React Native Parallax Scroll
Parallax scroll view for react-native
Stars: ✭ 385 (-25.1%)
Mutual labels:  parallax
React Scroll To
Scroll to a position in React
Stars: ✭ 348 (-32.3%)
Mutual labels:  smooth-scrolling
Minimap.vim
📡 Blazing fast minimap / scrollbar for vim, powered by code-minimap written in Rust.
Stars: ✭ 404 (-21.4%)
Mutual labels:  scrollbar
Fancyscrollview
A SwiftUI ScrollView Designed to imitate the App Store and Apple Music ScrollViews (with or without a Parallax Header)
Stars: ✭ 330 (-35.8%)
Mutual labels:  parallax
React Plx
React parallax component, powerful and lightweight
Stars: ✭ 469 (-8.75%)
Mutual labels:  parallax
Asscroll
Ash's Smooth Scroll 🍑
Stars: ✭ 324 (-36.96%)
Mutual labels:  smooth-scrolling
Sweet Scroll
🍭 ECMAScript2015+ & TypeScript Friendly, dependency-free smooth scroll library.
Stars: ✭ 380 (-26.07%)
Mutual labels:  smooth-scrolling
Reactscrollbar
Scrollbar component for React
Stars: ✭ 450 (-12.45%)
Mutual labels:  scrollbar

smooth

Smooth is a small JavaScript module based on VirtualScroll to create smooth scrolling and parallax effects on scroll. It works both with fake scrollbars and native scrolling.

Usage

npm install smooth-scrolling

import Smooth from 'smooth-scrolling'

const section = document.querySelector('.vs-section')
const smooth = new Smooth({
  native: true,
  section: section,
  ease: 0.1
})

smooth.init()

Options

  • listener: on-scroll events listener & parent container for all elements
  • direction : vertical or horizontal scrolling behavior
  • native: use the default scrollbar
  • section : the element to transform
  • ease : the easing value (usually between 0 and 1)
  • vs : you can pass some option for virtuall-scroll: limitInertia, mouseMultiplier, etc
  • preload : if set to false, there will be no resize function called after all images loaded
  • noscrollbar : if using virtual-scroll and set to true, it will not build a custom scrollbar
  • callback: function called on requestAnimationFrame

Methods

smooth.init()

Will add all event listeners and DOM elements.

smooth.on()

Will listen to either window scroll event (if native), otherwise VirtualScroll

smooth.off()

Will stop listening to onscroll/wheel events.

smooth.destroy()

Will remove all event listeners and DOM elements.

smooth.scrollTo(offset)

Basic scrollTo function.

Extends Smooth

import Smooth from 'smooth-scrolling'

class Custom extends Smooth {
  
  constructor(opt = {}) {
    super(opt)
    this.dom.section = opt.section
    this.dom.opacity = opt.opacity
  }
  
  run() {
    super.run()
    
    const current = Math.round(Math.abs(this.vars.current))
    const opacity = Math.max(0, Math.min(1 - current / (this.vars.height * .5), 1))
    
    this.dom.opacity.style.opacity = opacity.toFixed(2)
    this.dom.section.style[this.prefix] = this.getTransform(-this.vars.current.toFixed(2))
  }

  resize() {
    this.vars.bounding = this.dom.section.getBoundingClientRect().height - this.vars.height
    super.resize()
  }
}

export default Custom
// ...and later on
import Custom from './custom-smooth-scrolling'

const section = document.querySelector('.vs-section')
const opacity = document.querySelector('.vs-opacity')

const smooth = new Custom({
  section: section,
  opacity: opacity,
  ease: 0.1
})

smooth.init()

Development

git clone [email protected]:baptistebriel/smooth-scrolling.git

cd smooth-scrolling/ && npm i && npm run dev

You can use [http-server](https://www.npmjs.com/package/http-server) or MAMP to preview the demos.

Demos

npm run demo-parallax

npm run demo-parallax-page

npm run demo-horizontal

npm run demo-native-horizontal

npm run demo-opacity

npm run demo-scale

npm run demo-split

npm run demo-performances

Examples

Further understanding

If you didn't already read the tutorial, I highly recommend it. Smooth.js is basically what's explained on the blog post. I just needed a simple script to get things done without having to write lots of code every time I wanted to use this technique.

License

MIT, see LICENSE.md.

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].