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
Rebuild/destroy fullPage instance when transitioning from desktop to mobile #583
Comments
If you want to rebuild it, then you need to destroy it with the Use
|
Thanks for getting back to me. Progress, thanks, i did try this but missed the string quotes... It's reinitiaising/destroying as expected now. I still get an issue with duplicate dots in the navigation on any resize: I also get an error that comes from the call to: $(window).resize(function() { |
I assume this is because a fullpage instance has to exist before i can destroy it. Trying to use: if ($.fn.fullpage) { but it doesn't seem to work. |
Then you are doing something wrong. Content of the fiddle: createFullpage();
$('#destroy').click(function () {
$.fn.fullpage.destroy('all');
});
$('#create').click(function () {
createFullpage();
});
function createFullpage() {
$('#fullpage').fullpage({
sectionsColor: ['yellow', 'orange', '#C0C0C0', '#ADD8E6'],
navigation: true
});
} <div id="fullpage">
<div class="section">One</div>
<div class="section">
<div class="slide">
<div class="demo">Demo</div>Two</div>
<div class="slide">Three</div>
</div>
<div class="section">Third</div>
<div class="section">Four</div>
</div>
<div id="destroy"><input type="button" value="Destroy"/></div>
<div id="create"><input type="button" value="Create"/></div> If you are able to reproduce your error in the fiddle, I will be able to help you. Otherwise you should check your code. |
Hi, thanks for getting back. I've built on top of your fiddle adding a resize function, you can see the problem i am having - just resize the viewport till it destroys and then back again. You will see the navigation dot issue. (Link updated) You can also see the js error: |
That's because you are creating fullpage tens of times, everytime you make the window bigger than 768px, one instance of fullpage.js is created. for 769px, another for 770px, 771px....etc You should control it with a flag variable... |
Just for completeness: I updated alvarotrigo's example with a flag variable, so fullPage.js won't be created multiple times |
Just wanted to say cheers for 'flagging' that. Was struggling with it, but managed to get the final pieces of my puzzle using @byzanth's jsfiddle :) Also cheers to @alvarotrigo for helping me understand why I needed to do it haha |
@porridj haha! @alvarotrigo is a kind and patient guy |
Here is an updated fiddle that includes the flag variable triggered on resize instead of just using the destroy/build buttons! http://jsfiddle.net/4vpepcsq/ |
@mcranisnational great tricks man.. but I've try to set width and height but it only reflect for height function only.. jsfiddle try any luck for this one.. since would like to make the page go normal when in landscape mode.. |
Add it here source [no button] |
thanks all! super helpful |
Hi,
Before I start, awesome plugin.
I'm building an app where i need to be able to rebuild the instance of fullpage on viewport resize.
Basically, I don't want to have fullPage on mobile (less than 768px), but I do on desktop sizes (greater than 768px), - i can't change this threshold, as it is part of a wider project setting.
I understand that I can call the plugin to work just for desktop:
There is a case where a user may resize the viewport from mobile to desktop.
Is it possible to rebuild/destroy fullPage when it crosses that threshold?
My initialisation code:
Calling the function:
…doesn’t destroy the instance from initialisation. Alternatively ...
…this version on initialisationlooks and works fine on both desktop and mobile version, it doesn't seem to work on rebuilding/ the instance but does create duplicate navigation dots on resize.
Any help would be appreciated. Hope that all makes sense!
The text was updated successfully, but these errors were encountered: