alvarotrigo / react-fullpage

Official React.js wrapper for fullPage.js https://alvarotrigo.com/react-fullpage/
GNU General Public License v3.0
1.28k stars 179 forks source link

official offsetSections Extension not working in combination with react-fullpage #425

Closed vitrinekast closed 1 year ago

vitrinekast commented 1 year ago

I'm unable to get the offsetSections extension to work out of the box using react-fullpage.

Description

As soon as the user starts scrolling, i get the following error: Uncaught TypeError: s.offsetSections.getSectionPosition_ is not a function

Screenshot 2023-09-29 at 12 47 33

using the following isolated setup for the page (copy paste from the delivered example html file)

"use client";

import React from "react";
import ReactFullpage from "@fullpage/react-fullpage";

const pluginWrapper = () => {
  require("../../lib/fullpage.offsetSections.min.js");
};

export default function Fullpage() {
  return (
    <ReactFullpage
      pluginWrapper={pluginWrapper}
      licenseKey={"the-key"}
      offsetSections={true}
      render={({ state, fullpageApi }) => {
        return (
          <ReactFullpage.Wrapper>
            <div className="section" data-percentage="90">
              <div className="slide">
                <h1>Section 1</h1>
              </div>
              <div className="slide">
                <h1>Slide 1.2</h1>
              </div>
              <div className="slide">
                <h1>Slide 1.3</h1>
              </div>
            </div>
            <div className="section"-percentage="20" data-centered="true">
              <di className="intro">
                <h1>Section 2</h1>
                <p>This section is using `data-percentage="80"`.</p>
                <p>If you don't want to center it vertically, you could use `data-centered="false"`. See section 4.</p>
              </di>
            </div>
          </ReactFullpage.Wrapper>
        );
      }}
    />
  );
}

Possible fix?

To try something, i've changed within the delivered fullpage.offsetSections.min.js (t.getSectionPosition... to (t.getSectionPosition_, and that seems to have done the trick, as far as i can see now.

Doesn't seem like a very safe solution, but at least i'll be able to use the package for now. Will be great if this can be fixed for the next user! (Or, if you could let me know if this is a safe bet to use in production)

Versions

alvarotrigo commented 1 year ago

The latest version of Offset Sections is 0.1.2. It seems you are using a very old one or that you haven't purchased it.

You can get the Offset Sections extension for fullPage.js version 4 on the fullpage.js extensions page.

If you still having problems with the latest version, feel free to use the contact form and send us an email using the email used for the purchase of the extension.

alvarotrigo commented 1 year ago

Apologies for the late reply btw!! 🙏