alvarotrigo / react-fullpage

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

Is there any way to pass the MAIN_SELECTOR by customization, to cover the default value "fullpage" #318

Closed MapleShaw closed 2 years ago

MapleShaw commented 2 years ago

Description

image I use two DIV to handle the responsive between desktop and mobile, so there are two in different components, but in the same page.

It will cause the error "Fullpage.js can only be initialized once and you are doing it multiple times!"

Is there any way to pass the MAIN_SELECTOR by customization, to cover the default value "fullpage".

alvarotrigo commented 2 years ago

Change the IDs so you only initialize it once. Use different initializations for mobile than for desktop.

Something like:


if(inDesktop){
   new fullpage('#fullpage-desktop', {...});
}
else{
      new fullpage('#fullpage-mobile', {...});
}
MapleShaw commented 2 years ago

@alvarotrigo appreciate for reply, in that way, does it means I can not initialize in this way? image

alvarotrigo commented 2 years ago

You have to make sure to only initialize one instance of fullPage.js. And at the moment you are initializing two as both have the same ID.

MapleShaw commented 2 years ago

Got it, thanks so much!