Skip to content

Commit

Permalink
- Solve problem when using responsive together with `autoScrolling:…
Browse files Browse the repository at this point in the history
…false`. alvarotrigo#957
  • Loading branch information
alvarotrigo committed Jan 16, 2015
1 parent a12a655 commit 501b637
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 60 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![preview](https://raw.github.com/alvarotrigo/fullPage.js/master/examples/imgs/intro.png)
![compatibility](https://raw.github.com/alvarotrigo/fullPage.js/master/examples/imgs/compatible.gif)
![fullPage.js version](http://img.shields.io/badge/fullPage.js-v2.5.3-brightgreen.svg)
![fullPage.js version](http://img.shields.io/badge/fullPage.js-v2.5.4-brightgreen.svg)
[![License](http://img.shields.io/badge/License-MIT-blue.svg)](http://opensource.org/licenses/MIT)
A simple and easy to use plugin to create fullscreen scrolling websites (also known as single page websites).
It allows the creation of fullscreen scrolling websites, as well as adding some landscape sliders inside the sections of the site.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fullpage.js",
"version": "2.5.3",
"version": "2.5.4",
"homepage": "http://alvarotrigo.com/fullPage/",
"authors": [
"Alvaro Trigo https://github.com/alvarotrigo"
Expand Down
48 changes: 30 additions & 18 deletions jquery.fullPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* fullPage 2.5.3
* fullPage 2.5.4
* https://github.com/alvarotrigo/fullPage.js
* MIT licensed
*
Expand Down Expand Up @@ -77,8 +77,8 @@
//Apple devices (laptops, mouses...)
var scrollDelay = 600;

$.fn.fullpage.setAutoScrolling = function(value){
options.autoScrolling = value;
$.fn.fullpage.setAutoScrolling = function(value, type){
setVariableState('autoScrolling', value, type);

var element = $('.fp-section.active');

Expand All @@ -88,7 +88,7 @@
'height' : '100%'
});

$.fn.fullpage.setRecordHistory(options.recordHistory);
$.fn.fullpage.setRecordHistory(options.recordHistory, 'internal');

//for IE touch devices
container.css({
Expand All @@ -107,7 +107,7 @@
'height' : 'initial'
});

$.fn.fullpage.setRecordHistory(false);
$.fn.fullpage.setRecordHistory(false, 'internal');

//for IE touch devices
container.css({
Expand All @@ -126,15 +126,15 @@
/**
* Defines wheter to record the history for each hash change in the URL.
*/
$.fn.fullpage.setRecordHistory = function(value){
recordHistory = value;
$.fn.fullpage.setRecordHistory = function(value, type){
setVariableState('recordHistory', value, type);
};

/**
* Defines the scrolling speed
*/
$.fn.fullpage.setScrollingSpeed = function(value){
options.scrollingSpeed = value;
$.fn.fullpage.setScrollingSpeed = function(value, type){
setVariableState('scrollingSpeed', value, type);
};

/**
Expand Down Expand Up @@ -301,7 +301,7 @@
var nav;
var wrapperSelector = 'fullpage-wrapper';
var isScrollAllowed = { 'up':true, 'down':true, 'left':true, 'right':true };
var recordHistory = options.recordHistory;
var originals = jQuery.extend(true, {}, options); //deep copy

$.fn.fullpage.setAllowScrolling(true);

Expand Down Expand Up @@ -407,7 +407,7 @@
}

}).promise().done(function(){
$.fn.fullpage.setAutoScrolling(options.autoScrolling);
$.fn.fullpage.setAutoScrolling(options.autoScrolling, 'internal');

//the starting point is a slide?
var activeSlide = $('.fp-section.active').find('.fp-slide.active');
Expand Down Expand Up @@ -1277,12 +1277,12 @@
var isResponsive = container.hasClass('fp-responsive');
if ($(window).width() < options.responsive ){
if(!isResponsive){
$.fn.fullpage.setAutoScrolling(false);
$.fn.fullpage.setAutoScrolling(false, 'internal');
$('#fp-nav').hide();
container.addClass('fp-responsive');
}
}else if(isResponsive){
$.fn.fullpage.setAutoScrolling(true);
$.fn.fullpage.setAutoScrolling(originals.autoScrolling, 'internal');
$('#fp-nav').show();
container.removeClass('fp-responsive');
}
Expand Down Expand Up @@ -1612,7 +1612,7 @@
* Sets the URL hash.
*/
function setUrlHash(url){
if(recordHistory){
if(options.recordHistory){
location.hash = url;
}else{
//Mobile Chrome doesn't work the normal way, so... lets use HTML5 for phones :)
Expand Down Expand Up @@ -1760,10 +1760,9 @@
}

function silentLandscapeScroll(activeSlide){
var prevScrollingSpeepd = options.scrollingSpeed;
$.fn.fullpage.setScrollingSpeed (0);
$.fn.fullpage.setScrollingSpeed (0, 'internal');
landscapeScroll(activeSlide.closest('.fp-slides'), activeSlide);
$.fn.fullpage.setScrollingSpeed(prevScrollingSpeepd);
$.fn.fullpage.setScrollingSpeed(originals.scrollingSpeed, 'internal');
}

function silentScroll(top){
Expand Down Expand Up @@ -1803,7 +1802,7 @@
* Destroys fullpage.js plugin events and optinally its html markup and styles
*/
$.fn.fullpage.destroy = function(all){
$.fn.fullpage.setAutoScrolling(false);
$.fn.fullpage.setAutoScrolling(false, 'internal');
$.fn.fullpage.setAllowScrolling(false);
$.fn.fullpage.setKeyboardScrolling(false);

Expand Down Expand Up @@ -1876,6 +1875,19 @@
$('html, body').scrollTop(0);
}

/*
* Sets the state for a variable with multiple states (original, and temporal)
* Some variables such as `autoScrolling` or `recordHistory` might change automatically its state when using `responsive` or `autoScrolling:false`.
* This function is used to keep track of both states, the original and the temporal one.
* If type is not 'internal', then we assume the user is globally changing the variable.
*/
function setVariableState(variable, value, type){
options[variable] = value;
if(type !== 'internal'){
originals[variable] = value;
}
}

/**
* Displays warnings
*/
Expand Down
Loading

0 comments on commit 501b637

Please sign in to comment.