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

constructor outdated? #1

Open
hrvstr opened this issue May 19, 2023 · 2 comments
Open

constructor outdated? #1

hrvstr opened this issue May 19, 2023 · 2 comments

Comments

@hrvstr
Copy link

hrvstr commented May 19, 2023

When I use the plugin as described in the example project I get this error in the console.

[Error] TypeError: undefined is not an object (evaluating 'this.rootElement.getAttribute')

	ScrollSnap (scroll-snap.js:14)
	Modulcode (Lenis.astro:15)

When looking at the code in scroll-snap.js I see that it calls this.lenis.wrapperNode and this.lenis.contentNode which do not seem to be available in recent versions of lenis at least. I replaced them with lenis.options.wrapper and lenis.options.content, which made the error disappear.

  constructor(lenis, { snapType }) {
    this.lenis = lenis;
    this.isHorizontal = this.lenis.direction === "horizontal"; // we can set different value in case we need snap for different axis.
    this.rootElement =
      this.lenis.options.wrapper === window
        ? this.lenis.options.content
        : this.lenis.options.wrapper;
    this.snapType =
      snapType ||
      this.rootElement.getAttribute("scroll-snap-type") ||
      "mandatory";

    this.initElements();
    lenis.on("scroll", this.onScroll);
  }
@hrvstr hrvstr changed the title Example code outdated? constructor outdated? May 19, 2023
@drewbaker
Copy link
Member

We actually have two branches. One for the old Lenox version, and one for the new version. Try the other branch and let me know if that works or not. Thanks for trying it out!

@hrvstr
Copy link
Author

hrvstr commented May 20, 2023

Ah sorry, I didn't notice the different branches. I tried the 1.0 branch now and got the same error. In the code, I still see references to this.lenis.wrapper.element for example. Thanks for your great work. I am actually using a custom version now that works pretty well.

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

No branches or pull requests

2 participants