Set boolean to true after scrolling on page using Alpine.js

PHOTO EMBED

Tue Mar 09 2021 19:11:16 GMT+0000 (Coordinated Universal Time)

Saved by @klick #html #alpinejs

<div
    class="justify-between py-6 md:flex"
    x-data="{
        open: false,
        hasScrolled: false,
        reactOnScroll() {
            if (this.$el.getBoundingClientRect().top < 120 && window.scrollY > 120) {
                this.hasScrolled = true;
            } else {
                this.hasScrolled = false;
            }
        } 
    }"
    x-init="reactOnScroll()"
    @scroll.window="reactOnScroll()"
>
content_copyCOPY