Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does anyone know how to implement it in React? #124

Closed
hungngodev opened this issue Jan 6, 2024 · 2 comments
Closed

Does anyone know how to implement it in React? #124

hungngodev opened this issue Jan 6, 2024 · 2 comments

Comments

@hungngodev
Copy link

No description provided.

@geosigno
Copy link
Owner

If anyone is interested in creating a React version, i'll be happy to help :)

@geosigno
Copy link
Owner

For the time being, this is working as shown below on the latest Next.js.

"use client";

import { useEffect, useRef } from "react";
import SimpleParallax from "simple-parallax-js";
import styles from "./page.module.css";

export default function Home() {
  const refImage = useRef(null);

  useEffect(() => {
    if (!refImage.current) {
      return;
    }
    new SimpleParallax(refImage.current, {
    });
  }, [refImage]);

  return (
    <main className={styles.main}>
      <div className={styles.description}>
        <p>
          simpleParallax.js is a simple and tiny JavaScript library that adds
          parallax effects on any images.
        </p>
        <img
          src="/image.png"
          alt="simpleParallax.js"
          className={styles.image}
          ref={refImage}
        />
      </div>
    </main>
  );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants