Skip to content

Instantly share code, notes, and snippets.

@alvarotrigo
Created December 9, 2019 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvarotrigo/5379d1ce316868d6e9b1a3607a6ca0aa to your computer and use it in GitHub Desktop.
Save alvarotrigo/5379d1ce316868d6e9b1a3607a6ca0aa to your computer and use it in GitHub Desktop.
test.js
jQuery(function($) {
new fullpage('#fullpage', {
//options here
licenseKey: '42FCE5FA-2C984AC1-B445D929-FDDADEC3',
scrollHorizontallyKey: 'B5F85F27-2D6D476E-A8CF7F27-2C0174BC',
autoScrolling:true,
fitToSection: false,
verticalCentered: false,
scrollHorizontally: true,
navigation: true,
navigationPosition: 'right',
resetSliders: false,
slidesNavigation: false,
showActiveTooltip: true,
css3: true,
scrollingSpeed: 1000,
easingcss3: 'cubic-bezier(0.215, 0.610, 0.070, 1.000)',
onLeave: function(origin, destination, direction) {
var leavingSection = this;
if(origin.index == 0 && direction =='down'){
$('.l-header').addClass("sticky");
}
else if(origin.index == 1 && direction == 'up'){
$('.l-header').removeClass("sticky");
}
},
afterSlideLoad: function(section, origin, destination, direction) {
var totalItems = section.item.querySelectorAll('.fp-slide').length;
var numContainer = section.item.querySelector('.slide-num');
numContainer.innerHTML = (destination.index + 1) + ' / ' + totalItems;
},
afterRender: function(){
var activeSection = document.querySelector('#quanta-concierge');
var activeSlide = activeSection.querySelector('.fp-slide.active');
var totalSlides = activeSection.querySelectorAll('.fp-slide').length;
var numContainer = activeSection.querySelector('.slide-num');
if(numContainer && activeSlide) {
numContainer.innerHTML = (index(activeSlide) + 1) + ' / ' + totalSlides;
}
}
});
/**
* Gets index from the passed element.
* @param {String} selector is optional.
*/
function index(item, selector) {
var children = selector != null? $(selector, item.parentNode) : item.parentNode.childNodes;
var num = 0;
for (var i=0; i<children.length; i++) {
if (children[i] == item) return num;
if (children[i].nodeType==1) num++;
}
return -1;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment