alvarotrigo / alvarotrigo/fullPage.js

If selected sections are not sequential the plugin wont work with scroll or arrows

Aberta
#1,913 3 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
JavaScript
Estrelas
35.4k
Forks
7.1k
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

Hey there! First of all, thanks for the great plugin! But I'm now having some issues that are making me rip my hair off..

I'm attempting to create sections that are visible while on desktop whereas others while on mobile.
They are alternated with different classes (mobile and desktop), if I pass the ".desktop" selector to the sectionSelector it doesn't work.
- Shouldn't it just seamlessly use the array created by the selector used even though there might be alternated sections?

I've tried a workaround by selecting all sections and shifting the index to the one I'm interested in the specified device width "onleave" by using moveTo method. But although it works with the arrows, it doesn't work with scroll without glitches and some going back and forth unintentionally.

``` javascript
var device = 'desktop',
deviceSelector = '.'+device,
allSelector = '.section',
$allBlocks = $(allSelector),
$deviceBlocks = $(deviceSelector)
;

var indexMap = {};
var indexDevice = 0;

$allBlocks.each(function(indexAll) {
if (this == $deviceBlocks[indexDevice]) {
indexMap[indexAll+1] = indexDevice;
indexDevice++;
}
});

function shiftIndex(nextIndex, direction) {
if (direction == 'down') {
var upper = nextIndex;

while(upper < $allBlocks.length) {
if (indexMap[++upper] !== undefined) {
return upper;
}
}
return undefined;

} else {
var lower = nextIndex;

while(lower > -1) {
if (indexMap[--lower] !== undefined) {
return lower;
}
}
return undefined;
}
}

$('#fullpage').fullpage({
sectionSelector: allSelector,
scrollingSpeed: 1000,
keyboardScrolling: true,
navigation: true,
animateAnchor: true,
easingcss3: 'ease',

onLeave: function(index, nextIndex, direction){
if (indexMap[nextIndex] === undefined) {
var newIndex = shiftIndex(nextIndex, direction);
if (newIndex) {
$.fn.fullpage.moveTo(newIndex);
}
return false;
}
}
});
```
- Shouldn't it just work exactly the same for the different ways of interacting?

Any help on the issue would be much appreciated. Thanks again! ;)

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.