Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Create a new method with passed 3 arguments to switch fullpage.js
- */
- const switchFullPage = switcher.bind(null, trackWindowSizes,fullpageInit, fullpageDestroy);
- /*
- * Track window changes to disable on small screens
- */
- $(window).on('resize', switchFullPage);
- /*
- * Initialize our switcher
- */
- switchFullPage();
- /*
- * Initialize fullpage.js only when it is not active
- */
- function fullpageInit() {
- if (!fullpageIsActive()) {
- $('#main').fullpage({
- anchors: ['page-1', 'page-2', 'page-3', 'page-4', 'page-5', 'page-6'],
- menu: '#slider-nav',
- scrollingSpeed: 1200,
- onLeave: function(index, nextIndex, direction){
- App.prototype.sectionContentParallax(index, nextIndex, direction);
- }
- });
- location.hash = '';
- }
- }
- /*
- * Destroy fullpage.js only if it is active
- */
- function fullpageDestroy() {
- if (fullpageIsActive()) {
- $.fn.fullpage.destroy('all');
- }
- }
- /*
- * Check if fullpage.js is initialized
- */
- function fullpageIsActive () {
- return $( 'html' ).hasClass( 'fp-enabled' );
- }
- /*
- * Check if window is small
- */
- function trackWindowSizes () {
- let w = window.matchMedia('(min-width: 780px)').matches,
- h = window.matchMedia('(min-height: 600px)').matches;
- return w && h;
- }
- /*
- * Takes 3 arguments of type function,
- * first one is condition that return true or false
- * second one is what to do when condition returns true
- * third is what to do if condition false
- */
- function switcher( condition, resolve, reject ) {
- const state = condition();
- if ( state ) {
- resolve();
- } else {
- reject();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement