Skip to content

Commit

Permalink
Merge pull request #4389 from alvarotrigo/dev
Browse files Browse the repository at this point in the history
Merging dev branch 4.0.7
  • Loading branch information
alvarotrigo authored May 9, 2022
2 parents e558fc7 + 83f28a6 commit a95be5e
Show file tree
Hide file tree
Showing 23 changed files with 140 additions and 69 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

---

![fullPage.js version](http://img.shields.io/badge/fullPage.js-v4.0.6-brightgreen.svg)
![fullPage.js version](http://img.shields.io/badge/fullPage.js-v4.0.7-brightgreen.svg)
[![License](https://img.shields.io/badge/License-GPL-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.html)
[![PayPal Donate](https://img.shields.io/badge/donate-PayPal.me-ff69b4.svg)](https://www.paypal.me/alvarotrigo/9.95)
[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/fullpage.js/badge?style=rounded)](https://www.jsdelivr.com/package/npm/fullpage.js)
Expand Down Expand Up @@ -772,7 +772,7 @@ new fullpage('#fullpage', {
anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'],

afterLoad: function(origin, destination, direction, trigger){
var loadedSection = this;
var origin = this;

//using index
if(origin.index == 2){
Expand Down
2 changes: 1 addition & 1 deletion dist/fullpage.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* fullPage 4.0.6
* fullPage 4.0.7
* https://github.com/alvarotrigo/fullPage.js
*
* @license GPLv3 for open source use only
Expand Down
4 changes: 2 additions & 2 deletions dist/fullpage.extensions.min.js

Large diffs are not rendered by default.

85 changes: 58 additions & 27 deletions dist/fullpage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* fullPage 4.0.6
* fullPage 4.0.7
* https://github.com/alvarotrigo/fullPage.js
*
* @license GPLv3 for open source use only
Expand Down Expand Up @@ -1419,10 +1419,10 @@
var change = to - start;
var currentTime = 0;
var increment = 20;
var isCallbackFired = false;
setState({
activeAnimation: true
});
var isCallbackFired = false; // Making sure we can trigger a scroll animation
}); // Making sure we can trigger a scroll animation
// when css scroll snap is active. Temporally disabling it.

if (element === doc.body) {
Expand Down Expand Up @@ -2605,7 +2605,7 @@
this.focusedElem.blur();
}

if ($(OVERFLOW_SEL, getState().activeSection.item)[0]) {
if ($(OVERFLOW_SEL + ACTIVE_SEL, getState().activeSection.item)[0]) {
this.focusedElem = $(OVERFLOW_SEL, getState().activeSection.item)[0];
this.focusedElem.focus();
}
Expand Down Expand Up @@ -3517,9 +3517,12 @@

function afterSectionLoads(v) {
if (getOptions().fitToSection) {
css(doc.body, {
'scroll-snap-type': 'y mandatory'
});
// Removing CSS snaps for auto-scrolling sections
if (hasClass($(SECTION_ACTIVE_SEL)[0], AUTO_HEIGHT)) {
css(doc.body, {
'scroll-snap-type': 'none'
});
}
}

setState({
Expand Down Expand Up @@ -3707,12 +3710,6 @@
function touchMoveHandler(e) {
var activeSection = closest(e.target, SECTION_SEL) || getState().activeSection.item;
var hasActiveSectionOverflow = scrollOverflowHandler.isScrollable(getState().activeSection);
var isVerticalMovementEnough = Math.abs(touchStartY - touchEndY) > win.innerHeight / 100 * getOptions().touchSensitivity;
var isHorizontalMovementEnough = Math.abs(touchStartX - touchEndX) > getWindowWidth() / 100 * getOptions().touchSensitivity;
var isHorizontalPredominantMove = $(SLIDES_WRAPPER_SEL, activeSection).length && Math.abs(touchStartX - touchEndX) > Math.abs(touchStartY - touchEndY);
var directionH = touchStartX > touchEndX ? 'right' : 'left';
var directionV = touchStartY > touchEndY ? 'down' : 'up';
var direction = isHorizontalPredominantMove ? directionH : directionV;

if (isReallyTouch(e)) {
setState({
Expand All @@ -3730,6 +3727,12 @@
var touchEvents = getEventsPage(e);
touchEndY = touchEvents.y;
touchEndX = touchEvents.x;
var isVerticalMovementEnough = Math.abs(touchStartY - touchEndY) > win.innerHeight / 100 * getOptions().touchSensitivity;
var isHorizontalMovementEnough = Math.abs(touchStartX - touchEndX) > getWindowWidth() / 100 * getOptions().touchSensitivity;
var isHorizontalPredominantMove = $(SLIDES_WRAPPER_SEL, activeSection).length && Math.abs(touchStartX - touchEndX) > Math.abs(touchStartY - touchEndY);
var directionH = touchStartX > touchEndX ? 'right' : 'left';
var directionV = touchStartY > touchEndY ? 'down' : 'up';
var direction = isHorizontalPredominantMove ? directionH : directionV;
setState({
touchDirection: direction
}); //if movement in the X axys is greater than in the Y and the currect section has slides...
Expand Down Expand Up @@ -3989,7 +3992,7 @@

docAddEvent('keydown', keydownHandler); // for fitToSection:true

$body.addEventListener('keydown', cancelDirectionKeyEvents); //to prevent scrolling while zooming
$body.addEventListener('keydown', onBodyClick); //to prevent scrolling while zooming

docAddEvent('keyup', keyUpHandler);
EventEmitter.on('onDestroy', onDestroy$5);
Expand All @@ -3999,19 +4002,23 @@
clearTimeout(g_keydownId);
docRemoveEvent('keydown', keydownHandler);
docRemoveEvent('keyup', keyUpHandler);
}

function isInsideInput() {
var activeElement = doc.activeElement;
return matches(activeElement, 'textarea') || matches(activeElement, 'input') || matches(activeElement, 'select') || getAttr(activeElement, 'contentEditable') == "true" || getAttr(activeElement, 'contentEditable') == '';
} //Sliding with arrow keys, both, vertical and horizontal


function keydownHandler(e) {
clearTimeout(g_keydownId);
var activeElement = doc.activeElement;
var keyCode = e.keyCode;
var isPressingHorizontalArrows = [37, 39].indexOf(keyCode) > -1;
var canScrollWithKeyboard = getOptions().autoScrolling || isPressingHorizontalArrows; //tab?

if (keyCode === 9) {
onTab(e);
} else if (!matches(activeElement, 'textarea') && !matches(activeElement, 'input') && !matches(activeElement, 'select') && getAttr(activeElement, 'contentEditable') !== "true" && getAttr(activeElement, 'contentEditable') !== '' && getOptions().keyboardScrolling && canScrollWithKeyboard) {
} else if (!isInsideInput() && getOptions().keyboardScrolling && canScrollWithKeyboard) {
g_controlPressed = e.ctrlKey;
g_keydownId = setTimeout(function () {
onkeydown(e);
Expand Down Expand Up @@ -4202,8 +4209,20 @@
}

function shouldCancelKeyboardNavigation(e) {
// https://keycode.info/for/34
// 40 = arrow down
// 38 = arrow up
// 32 = spacebar
// 33 = PageUp
// 34 = PageDown
var keyControls = [40, 38, 32, 33, 34];
return keyControls.indexOf(e.keyCode) > -1 && !state.isBeyondFullpage;
}

function onBodyClick(e) {
if (!isInsideInput()) {
cancelDirectionKeyEvents(e);
}
} //preventing the scroll with arrow keys & spacebar & Page Up & Down keys


Expand Down Expand Up @@ -4953,15 +4972,27 @@

setPageStatus(slideIndex, slideAnchorLink, anchorLink);
updateState();
} //small timeout in order to avoid entering in hashChange event when scrolling is not finished yet

}

clearTimeout(g_scrollId);
g_scrollId = setTimeout(function () {
setState({
isScrolling: false
});
}, 100);
if (getOptions().fitToSection) {
// Small timeout in order to avoid entering in hashChange event when scrolling is not finished yet
clearTimeout(g_scrollId);
g_scrollId = setTimeout(function () {
setState({
isScrolling: false
});
var fixedSections = state.sections.filter(function (section) {
var sectionValues = section.item.getBoundingClientRect();
return Math.round(sectionValues.bottom) === Math.round(getWindowHeight()) || Math.round(sectionValues.top) === 0;
}); // No section is fitting the viewport? Let's fix that!

if (!fixedSections.length) {
css(doc.body, {
'scroll-snap-type': 'y mandatory'
});
}
}, 300);
}
}
}
}
Expand Down Expand Up @@ -5124,7 +5155,7 @@
});
});
var t = ["-"];
var n = "2022-3-19".split("-"),
var n = "2022-4-9".split("-"),
e = new Date(n[0], n[1], n[2]),
i = ["se", "licen", "-", "v3", "l", "gp"];

Expand All @@ -5133,7 +5164,7 @@
}

function o(t) {
return isNaN(t) ? t.charCodeAt(0) - 72 : t;
return t ? isNaN(t) ? t.charCodeAt(0) - 72 : t : "";
}

function a(t) {
Expand Down Expand Up @@ -5540,7 +5571,7 @@
}; //public functions


FP.version = '4.0.6';
FP.version = '4.0.7';
FP.test = Object.assign(FP.test, {
top: '0px',
translate3d: 'translate3d(0px, 0px, 0px)',
Expand Down
2 changes: 1 addition & 1 deletion dist/fullpage.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/fullpage.min.css.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/fullpage.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lang/chinese/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

---

![fullPage.js version](http://img.shields.io/badge/fullPage.js-v4.0.6,2-brightgreen.svg)
![fullPage.js version](http://img.shields.io/badge/fullPage.js-v4.0.7,2-brightgreen.svg)
[![License](https://img.shields.io/badge/License-GPL-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.html)
[![PayPal Donate](https://img.shields.io/badge/donate-PayPal.me-ff69b4.svg)](https://www.paypal.me/alvarotrigo/9.95)
[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/fullpage.js/badge?style=rounded)](https://www.jsdelivr.com/package/npm/fullpage.js)
Expand Down
2 changes: 1 addition & 1 deletion lang/french/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

---

![fullPage.js version](http://img.shields.io/badge/fullPage.js-v4.0.6-brightgreen.svg)
![fullPage.js version](http://img.shields.io/badge/fullPage.js-v4.0.7-brightgreen.svg)
[![License](https://img.shields.io/badge/License-GPL-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.html)
[![PayPal Donate](https://img.shields.io/badge/donate-PayPal.me-ff69b4.svg)](https://www.paypal.me/alvarotrigo/9.95)
[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/fullpage.js/badge?style=rounded)](https://www.jsdelivr.com/package/npm/fullpage.js)
Expand Down
2 changes: 1 addition & 1 deletion lang/korean/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</p>
---

![fullPage.js version](http://img.shields.io/badge/fullPage.js-v4.0.6-brightgreen.svg)
![fullPage.js version](http://img.shields.io/badge/fullPage.js-v4.0.7-brightgreen.svg)
[![License](https://img.shields.io/badge/License-GPL-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.html)
[![PayPal](https://img.shields.io/badge/donate-PayPal.me-ff69b4.svg)](https://www.paypal.me/alvarotrigo/9.95)
[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/fullpage.js/badge?style=rounded)](https://www.jsdelivr.com/package/npm/fullpage.js)
Expand Down
2 changes: 1 addition & 1 deletion lang/russian/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

---

![Версия fullPage.js](http://img.shields.io/badge/fullPage.js-v4.0.6-brightgreen.svg)
![Версия fullPage.js](http://img.shields.io/badge/fullPage.js-v4.0.7-brightgreen.svg)
[![Лицензия](https://img.shields.io/badge/License-GPL-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.html)
[![Перечисление на PayPal](https://img.shields.io/badge/donate-PayPal.me-ff69b4.svg)](https://www.paypal.me/alvarotrigo/9.95)
[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/fullpage.js/badge?style=rounded)](https://www.jsdelivr.com/package/npm/fullpage.js)
Expand Down
2 changes: 1 addition & 1 deletion lang/spanish/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

---

![fullPage.js version](http://img.shields.io/badge/fullPage.js-v4.0.6-brightgreen.svg)
![fullPage.js version](http://img.shields.io/badge/fullPage.js-v4.0.7-brightgreen.svg)
[![License](https://img.shields.io/badge/License-GPL-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.html)
[![PayPal Donate](https://img.shields.io/badge/donate-PayPal.me-ff69b4.svg)](https://www.paypal.me/alvarotrigo/9.95)
[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/fullpage.js/badge?style=rounded)](https://www.jsdelivr.com/package/npm/fullpage.js)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fullpage.js",
"version": "4.0.6",
"version": "4.0.7",
"description": "Create beautiful fullscreen snap scrolling websites",
"main": "dist/fullpage.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import resolve from "@rollup/plugin-node-resolve";
import babel from "@rollup/plugin-babel";

const licenseContent = `/*!
* fullPage 4.0.6
* fullPage 4.0.7
* https://github.com/alvarotrigo/fullPage.js
*
* @license GPLv3 for open source use only
Expand Down
2 changes: 1 addition & 1 deletion src/css/fullpage.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* fullPage 4.0.6
* fullPage 4.0.7
* https://github.com/alvarotrigo/fullPage.js
*
* @license GPLv3 for open source use only
Expand Down
3 changes: 2 additions & 1 deletion src/js/common/scrollTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ export function scrollTo(element, to, duration, callback) {
var change = to - start;
var currentTime = 0;
var increment = 20;
setState({activeAnimation: true});
var isCallbackFired = false;

setState({activeAnimation: true});

// Making sure we can trigger a scroll animation
// when css scroll snap is active. Temporally disabling it.
if(element === doc.body){
Expand Down
2 changes: 1 addition & 1 deletion src/js/fullpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function setAPI(){
};

//public functions
FP.version = '4.0.6';
FP.version = '4.0.7';

FP.test = Object.assign(FP.test, {
top: '0px',
Expand Down
31 changes: 24 additions & 7 deletions src/js/keyboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function bindEvents(){
utils.docAddEvent('keydown', keydownHandler);

// for fitToSection:true
$body.addEventListener('keydown', cancelDirectionKeyEvents);
$body.addEventListener('keydown', onBodyClick);

//to prevent scrolling while zooming
utils.docAddEvent('keyup', keyUpHandler);
Expand All @@ -48,11 +48,20 @@ function onDestroy(){
utils.docRemoveEvent('keyup', keyUpHandler);
}

function isInsideInput(){
var activeElement = doc.activeElement;

return utils.matches(activeElement, 'textarea') ||
utils.matches(activeElement, 'input') ||
utils.matches(activeElement, 'select') ||
utils.getAttr(activeElement, 'contentEditable') == "true" ||
utils.getAttr(activeElement, 'contentEditable') == '';
}

//Sliding with arrow keys, both, vertical and horizontal
function keydownHandler(e) {
clearTimeout(g_keydownId);

var activeElement = doc.activeElement;
var keyCode = e.keyCode;
var isPressingHorizontalArrows = [37,39].indexOf(keyCode) > -1;
var canScrollWithKeyboard = getOptions().autoScrolling || isPressingHorizontalArrows;
Expand All @@ -62,11 +71,7 @@ function keydownHandler(e) {
onTab(e);
}

else if(!utils.matches(activeElement, 'textarea') &&
!utils.matches(activeElement, 'input') &&
!utils.matches(activeElement, 'select') &&
utils.getAttr(activeElement, 'contentEditable') !== "true" &&
utils.getAttr(activeElement, 'contentEditable') !== '' &&
else if( !isInsideInput() &&
getOptions().keyboardScrolling &&
canScrollWithKeyboard){

Expand Down Expand Up @@ -254,10 +259,22 @@ function isFocusOutside(e){
}

function shouldCancelKeyboardNavigation(e){
// https://keycode.info/for/34
// 40 = arrow down
// 38 = arrow up
// 32 = spacebar
// 33 = PageUp
// 34 = PageDown
var keyControls = [40, 38, 32, 33, 34];
return keyControls.indexOf(e.keyCode) > -1 && !state.isBeyondFullpage;
}

function onBodyClick(e){
if(!isInsideInput()){
cancelDirectionKeyEvents(e);
}
}

//preventing the scroll with arrow keys & spacebar & Page Up & Down keys
function cancelDirectionKeyEvents(e){
if(shouldCancelKeyboardNavigation(e) && !utils.closest(e.target, OVERFLOW_SEL)){
Expand Down
2 changes: 1 addition & 1 deletion src/js/mixed/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a95be5e

Please sign in to comment.