PLATFORM
  • Apps

    Full-stack Laravel apps, built with AI

  • Sites

    Websites, apps, and more โ€” one site workspace

  • Designer

    AI-crafted Tailwind designs

  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

COMMUNITY

javascript on window scroll

window.addEventListener('scroll', function() {
    console.log('scrolling');
});

// Alternative version
window.onscroll = function() {
    console.log('scrolling');
};

What's the equivalent of the following in plain JS?

$(window).scroll(function() { }); I'm also looking to animate scroll, e.g.:

$('html, body').animate({scrollTop:1750}, 'slow'); Should I be using

BETA Snippet explanation automatically generated by OpenAI:

Here is what the above code is doing:
1. On scrolling, the onscroll event is fired.
2. The function is defined.
3. The function is called.
4. The function is anonymous.
5. The function is assigned to the window.onscroll property.
6. The

Snippet By Tony Lea

ยท

Created October 19th, 2021

ยท

Report Snippet