79558920

Date: 2025-04-07 01:19:00
Score: 0.5
Natty:
Report link

You can do it easly with gsap

<script>
import { onMounted, onBeforeUnmount, ref } from 'vue';
import gsap from 'gsap';
import { ScrollToPlugin } from 'gsap/ScrollToPlugin';
gsap.registerPlugin(ScrollToPlugin);

export default {
  setup() {
    const containerRef = ref(null);

    function handleScroll(event) {
      if (containerRef.value) {
        event.preventDefault();

        const container = containerRef.value;
        const { deltaY, delateX } = event;

        // Reverse scroll: delta > 0 means scroll left
        const newScrollY = container.scrollLeft + deltaY;

        gsap.to(container, {
          scrollTo: {
            x: newScrollY,
            autoKill: true,
          },
          duration: 0.5,
          ease: 'power2.out',
        });
      }
    }

    onMounted(() => {
      const el = containerRef.value;
      if (el) {
        el.addEventListener('wheel', handleScroll, { passive: false });
      }
    });

    onBeforeUnmount(() => {
      const el = containerRef.value;
      if (el) {
        el.removeEventListener('wheel', handleScroll);
      }
    });

    return {
      containerRef,
    };
  },
};
</script>

<template>
  <main>
    <div class="layout-wrapper">
      <div class="horizontal-container" ref="containerRef">
        <div class="horizontal-section">1 ProjectsSection</div>
        <div class="horizontal-section">2 ContactSection</div>
        <div class="horizontal-section">3 HomeSection</div>
      </div>

      <footer>
        <p>&copy; 2025 Onyedikachukwu Okonkwo</p>
      </footer>
    </div>
  </main>
</template>

<style>
.horizontal-container {
  height: calc(100vh - 100px);
  width: auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  overflow: hidden; /* Disable native scroll */
  position: relative;
}

.horizontal-section {
  width: 100vw;
  height: 100%;
  min-height: 100%;
  min-width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>

You can play around with it in: https://stackblitz.com/edit/vue-rwffnzpr?file=src%2FApp.vue

Reasons:
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Ebraheem Ahetari