All Projects → ederssouza → vanillajs-scrollspy

ederssouza / vanillajs-scrollspy

Licence: MIT license
ScrollSpy in pure JavaScript

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to vanillajs-scrollspy

react-smart-scroll
Efficient rendering of long lists in React
Stars: ✭ 27 (-42.55%)
Mutual labels:  scroll, scrollable
simple-scrollspy
Simple scrollspy without jQuery, no dependencies
Stars: ✭ 53 (+12.77%)
Mutual labels:  scroll, scrollspy
rippledb
Embeddable key-value database engine in pure TypeScript, based on LSM-Tree
Stars: ✭ 33 (-29.79%)
Mutual labels:  pure-javascript
scroll-sync-react
A scroll syncing library for react that is up to date
Stars: ✭ 49 (+4.26%)
Mutual labels:  scroll
Modern.JS
모던 자바스크립트 라이브러리/프레임워크 × KIPFA(한국인터넷전문가협회)
Stars: ✭ 16 (-65.96%)
Mutual labels:  scrollmagic
sweetconfirm.js
👌A useful zero-dependencies, less than 434 Bytes (gzipped), pure JavaScript & CSS solution for drop an annoying pop-ups confirming the submission of form in your web apps.
Stars: ✭ 34 (-27.66%)
Mutual labels:  pure-javascript
RollingNotice-Swift
滚动公告、广告,支持灵活自定义cell。淘宝、口碑、京东、美团、天猫等等一切滚动广告 Roll Notice or Advertising, customize cell as UITableViewCell supported, Swift version is also ready
Stars: ✭ 109 (+131.91%)
Mutual labels:  scroll
budget-manager
Easy-to-use, lightweight and self-hosted solution to track your finances
Stars: ✭ 20 (-57.45%)
Mutual labels:  pure-javascript
urlpack
Pure JavaScript toolkit for data URLs (MessagePack, Base58 and Base62)
Stars: ✭ 51 (+8.51%)
Mutual labels:  pure-javascript
scrollRulerView
请使用 CYRuler (Please use CYRuler)
Stars: ✭ 31 (-34.04%)
Mutual labels:  scroll
react-shadow-scroll
Component that customizes the list and inserts shadow when scrolling exists
Stars: ✭ 28 (-40.43%)
Mutual labels:  scroll
QuickTraceiOSLogger
A real time iOS log trace tool, view iOS log with pc web browser under local area network, which will automatically scroll like xcode. 一个实时的iOS日志跟踪工具,在局域网中使用 PC Web 浏览器查看 iOS 日志,它将像xcode一样自动滚动。
Stars: ✭ 16 (-65.96%)
Mutual labels:  scroll
radiaSlider
circular/linear knob-style slider
Stars: ✭ 18 (-61.7%)
Mutual labels:  pure-javascript
JhScrollActionSheetView
JhScrollActionSheetView - UIcollectionView横向滚动,类似微博新版的详情页分享界面,可设置单排或双排显示,title不设置不显示title,如果想实现发送站内用户的功能,自己可以改一下代码
Stars: ✭ 13 (-72.34%)
Mutual labels:  scroll
react-native-awesome-pin
A highly interactive and customisable PIN code screen for React Native.
Stars: ✭ 28 (-40.43%)
Mutual labels:  pure-javascript
any-scroll
🚀 模拟scrollview, 支持pc/移动端, 让实现Tab/Slider等组件轻而易举.
Stars: ✭ 45 (-4.26%)
Mutual labels:  scroll
LC-switch
Superlight vanilla javascript plugin improving forms look and functionality
Stars: ✭ 31 (-34.04%)
Mutual labels:  pure-javascript
react-is-scrolling
Simply detect if users are scrolling in your components in a declarative API
Stars: ✭ 17 (-63.83%)
Mutual labels:  scroll
respinner
Pretty and customizable svg spinners for React.js
Stars: ✭ 89 (+89.36%)
Mutual labels:  pure-javascript
universalSmoothScroll
A cross-browser smooth-scrolling API which supports multiple and interruptable scroll-animations on all DOM's elements, even at the same time!
Stars: ✭ 46 (-2.13%)
Mutual labels:  scroll

VanillaJS ScrollSpy

GitHub npm npm npm

ScrollSpy in pure JavaScript.

Installation

$ npm install vanillajs-scrollspy --save

How to use

  • menu: HTML selector (#id, .class, ...)
  • speed (optional): scroll speed, default value 2000
  • easing (optional): scroll type 'easeOutSine', 'easeInOutSine' or 'easeInOutQuint', default value 'easeOutSine'

ES6

import VanillaScrollspy from 'vanillajs-scrollspy'

const menu = document.querySelector('#navbar')
const scrollspy = VanillaScrollspy({ menu })
scrollspy.init()

UMD in Browser

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vanillajs-scrollspy.min.js"></script>
<!-- or -->
<script src="./dist/vanillajs-scrollspy.min.js"></script>

After that the library will be available to the Global as VanillaScrollspy. Follow an example:

const menu = document.querySelector('#navbar')
const scrollspy = VanillaScrollspy({ menu })
scrollspy.init()

Examples

Basic template

Available in public/index.html.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>VanillaJS ScrollSpy</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }

      html, body {
        height: 100%;
      }

      nav {
        position: fixed;
        left: 0;
        right: 0;
        top: 0;
      }

      nav a.active {
        font-weight: bold;
      }

      .page {
        height: 100%;
        padding: 80px 0;
        width: 100%;
        background-color: #ddd;
      }

      .page:nth-child(even) { background-color: #fff; }
    </style>
  </head>

  <body>
    <nav id="navbar">
      <a href="#home" title="Home" class="active">Home</a>
      <a href="#portfolio" title="Portfolio">Portfolio</a>
      <a href="#about" title="About">About</a>
      <a href="#contact" title="Contact">Contact</a>
    </nav>

    <section id="home" class="page">
      <h2 class="title">Home</h2>
    </section>

    <section id="portfolio" class="page">
      <h2 class="title">Portfolio</h2>
    </section>

    <section id="about" class="page">
      <h2 class="title">About</h2>
    </section>

    <section id="contact" class="page">
      <h2 class="title">Contact</h2>
    </section>

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vanillajs-scrollspy.min.js"></script>
    <script>
      const menu = document.querySelector('#navbar')
      const scrollspy = VanillaScrollspy({ menu })
      scrollspy.init()
    </script>
  </body>
</html>

Controlling the speed

Choose a number greater than or equal to 1.

const menu = document.querySelector('#navbar')
const scrollspy = VanillaScrollspy({ menu, speed: 1000 })
scrollspy.init()

Changing scroll type

const menu = document.querySelector('#navbar')
const scrollspy = VanillaScrollspy({ menu, speed: 1000, easing: 'easeInOutQuint' })
scrollspy.init()

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

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