Closed
Description
if I hide sections with css media queries (display:none), even if i destroy and re-initialize the plugin (even programmatically changing .section classes ..es: sectionSelector: '.section.target-visible') the plugin keeps on scrolling (changing anchors #page-1 #page-2 etc) through invisible sections..
the only way i found is to remove them from the DOM but doing so i would have to re-add them on resize, which is not a "very clean" option...
sectionSelector: '.section:visible' has not worked either...
Activity
alvarotrigo commentedon Jun 14, 2016
I can not reproduce it in this fiddle.
The library stops scrolling when a section is hidden. Although of course, it doesn't continue to the next one, which I believe is the issue.
memob0x commentedon Jun 15, 2016
exactly.. what could i do to make it continue to section 4 without removing section 3 from the document?
also it would be cool if i could not be forced to destroy and re-init the plugin at that point to achieve that
EDIT: with "keeps on scrolling" i wanted to say that the best result i achieved (without removing sections) is actually near to what i want but with hidden sections anchors keeping updating in url (with a consequential "pause" in the scrolling process)...
[-]plugin keeps on scrolling through non-visible sections[/-][+]plugin keeps on updating url hash while scrolling through non-visible sections[data-anchor][/+][-]plugin keeps on updating url hash while scrolling through non-visible sections[data-anchor][/-][+]plugin keeps on updating url hash while scrolling through non-visible sections[data-anchor] / stops at the hidden sections[/+]alvarotrigo commentedon Jun 15, 2016
Right now probably nothing. It will require a library modification.
The topic has been marked as an enhancement. I'll see if I solve it for future releases.
The most you can do at the moment is destroy and initialize fullpage.js again without the section.
[-]plugin keeps on updating url hash while scrolling through non-visible sections[data-anchor] / stops at the hidden sections[/-][+]Ignore `display:none` sections.[/+]alessandrotp commentedon Sep 6, 2016
Hi guys!
I had the same issue, I wanted to skip a div but removing the class "section" would stop scrolling through the rest of the sections and using
display:none
would cause the scroll to stop on ghost sections.My solution was to dynamically comment the div that I wanted to skip:
It's not a definitive solution but it's a workaround that worked for me!
thisisfed commentedon Aug 4, 2017
I just solved this issue simply by using the $(".class or #id").remove()
Khusainov commentedon Aug 24, 2017
@memob0x The workaround that I used (without changing DOM and re-init fullpage) is to use OnLeave event to navigate through invisible sections:
getSectionByIndex function example:
function(index) { return $('.section').eq(index - 1); } // -1 because index starts from 1
isVisible function example:
function(section) { return $(section).is(':visible'); }
getNearestVisibleSectionIndex function example:
This solution allows to dynamically hide sections without re-init fullpage.
The only limitation that I found is the last section, because plugin will scroll to the first section even if you return 'false' from 'OnLeave'
ghost commentedon Jun 14, 2018
@Khusainov would you mind expanding on your answer? Have you got a complete working example i can implement? I am getting getSectionByIndex is not defined when trying your code and am a bit of a newbie to jQuery.
Thanks
Edit:
I managed to solve it
onLeave: function(index, nextIndex, direction){ var nextSection = getSectionByIndex(nextIndex); function getSectionByIndex(index) { return $('.section').eq(index - 1); } // -1 because index starts from 1 function isVisible(section) { return $(section).is(':visible'); } function getNearestVisibleSectionIndex(index, direction) { var step = direction === 'up' ? -1 : 1, sectionsCount = $('.section').length; while (index >=0 && index < sectionsCount && !isVisible(getSectionByIndex(index))) { index += step; } return index === sectionsCount ? -1 : index; } if(!isVisible(nextSection)) { var sectionIndex = getNearestVisibleSectionIndex(nextIndex, direction); if (sectionIndex !== -1) { jQuery.fn.fullpage.moveTo(sectionIndex); } return false; } },
Khusainov commentedon Aug 9, 2018
@stegster Glad to see that you managed it to work. But it's better to determine functions outside of onLeave function.
In your case it should be:
And then use it in onLeave function:
15 remaining items