Giter Club home page Giter Club logo

responsive-navbar's Introduction

Vanilla JS Responsive Nav with Smooth Scroll + Spy Scroll

Responsive Navbar

Description

Inittially started this project as part of Learn Vanilla JavaScript Challange No #3. I decided to make it more challanging by implementing SmoothScroll and SpyScroll. I found multiple ways of achieving this and tried out a few methods to gain a better understanding on how they work. I found Approach 3 (window.requestAnimationFrame()) to have the best browser compatibility.

Functionality

Smooth Scroll

  • Approach 1: window.scrollTo() - Scrolls to a particular set of coordinates in the document -- MDN Docs

  • Approach 2: element.scrollIntoView() - Scrolls the element's parent container such that the element on which scrollIntoView() is called is visible to the user -- MDN Docs

  • Approach 3: window.requestAnimationFrame() - Tells the browser that you wish to perform an animation and requests that the browser calls a specified function to update an animation before the next repaint. The method takes a callback as an argument to be invoked before the repaint -- MDN Docs

ScrollSpy

  1. Intersection Observer API - The Intersection Observer API provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document's viewport -- MDN Docs

responsive-navbar's People

Contributors

marius-adam avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.