From 30a16191e5bb14bb076ac1fd648272c2edef5cf9 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Tue, 17 May 2022 12:11:00 +0200 Subject: [PATCH 01/30] Update FunctionsAbout.md --- docs/FunctionsAbout.md | 67 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/docs/FunctionsAbout.md b/docs/FunctionsAbout.md index 1631c49..844537c 100644 --- a/docs/FunctionsAbout.md +++ b/docs/FunctionsAbout.md @@ -272,7 +272,7 @@ uss.scrollYBy(50, myContainer, () => console.log("Done"), false); - + setXStepLengthCalculator @@ -292,9 +292,14 @@ uss.scrollYBy(50, myContainer, () => console.log("Done"), false); isTemporary + + + shouldBeTested + + - + setYStepLengthCalculator @@ -314,9 +319,14 @@ uss.scrollYBy(50, myContainer, () => console.log("Done"), false); isTemporary + + + shouldBeTested + + - + setStepLengthCalculator @@ -336,6 +346,11 @@ uss.scrollYBy(50, myContainer, () => console.log("Done"), false); isTemporary + + + shouldBeTested + + @@ -1095,7 +1110,7 @@ The following table describes every entry of the `Input Parameters` column of th - + setXStepLengthCalculator @@ -1134,9 +1149,21 @@ The following table describes every entry of the `Input Parameters` column of th Setting a non-temporary StepLengthCalculator will overwrite the previous non-temporary one and discard any temporary one.
+ + + shouldBeTested + + + Boolean + + + If `true`, a dummy scroll-animation is performed _(no actual scroll takes place)_ to test the stepLengthCalculator.
+ If `false` the new calculator is directly set. + + - + setYStepLengthCalculator @@ -1175,9 +1202,21 @@ The following table describes every entry of the `Input Parameters` column of th Setting a non-temporary StepLengthCalculator will overwrite the previous non-temporary one and discard any temporary one.
+ + + shouldBeTested + + + Boolean + + + If `true`, a dummy scroll-animation is performed _(no actual scroll takes place)_ to test the stepLengthCalculator.
+ If `false` the new calculator is directly set. + + - + setStepLengthCalculator @@ -1217,7 +1256,19 @@ The following table describes every entry of the `Input Parameters` column of th Setting a non-temporary StepLengthCalculator will overwrite the previous non-temporary one and discard any temporary one.
- + + + shouldBeTested + + + Boolean + + + If `true`, a dummy scroll-animation is performed _(no actual scroll takes place)_ to test the stepLengthCalculator.
+ If `false` the new calculator is directly set. + + + setXStepLength @@ -2100,7 +2151,7 @@ The following table describes every entry of the `Input Parameters` column of th includeHiddenParents - + Boolean From fb7d0896ad3fe7ecc80757ccfc37d518fe3c7ac5 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Tue, 17 May 2022 12:12:10 +0200 Subject: [PATCH 02/30] Update FunctionsAbout.md --- docs/FunctionsAbout.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/FunctionsAbout.md b/docs/FunctionsAbout.md index 844537c..6dd0137 100644 --- a/docs/FunctionsAbout.md +++ b/docs/FunctionsAbout.md @@ -1157,8 +1157,8 @@ The following table describes every entry of the `Input Parameters` column of th Boolean - If `true`, a dummy scroll-animation is performed _(no actual scroll takes place)_ to test the stepLengthCalculator.
- If `false` the new calculator is directly set. + If true, a dummy scroll-animation is performed _(no actual scroll takes place)_ to test the stepLengthCalculator.
+ If false the new calculator is directly set. @@ -1210,8 +1210,8 @@ The following table describes every entry of the `Input Parameters` column of th Boolean - If `true`, a dummy scroll-animation is performed _(no actual scroll takes place)_ to test the stepLengthCalculator.
- If `false` the new calculator is directly set. + If true, a dummy scroll-animation is performed _(no actual scroll takes place)_ to test the stepLengthCalculator.
+ If false the new calculator is directly set. @@ -1264,8 +1264,8 @@ The following table describes every entry of the `Input Parameters` column of th Boolean - If `true`, a dummy scroll-animation is performed _(no actual scroll takes place)_ to test the stepLengthCalculator.
- If `false` the new calculator is directly set. + If true, a dummy scroll-animation is performed _(no actual scroll takes place)_ to test the stepLengthCalculator.
+ If false the new calculator is directly set. From dc491d4991986e8523ee79511d44f189f12953a8 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Tue, 17 May 2022 12:13:40 +0200 Subject: [PATCH 03/30] Update FunctionsAbout.md --- docs/FunctionsAbout.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/FunctionsAbout.md b/docs/FunctionsAbout.md index 6dd0137..9e6395a 100644 --- a/docs/FunctionsAbout.md +++ b/docs/FunctionsAbout.md @@ -1157,7 +1157,7 @@ The following table describes every entry of the `Input Parameters` column of th Boolean - If true, a dummy scroll-animation is performed _(no actual scroll takes place)_ to test the stepLengthCalculator.
+ If true, a dummy scroll-animation is performed (no actual scroll takes place) to test the stepLengthCalculator.
If false the new calculator is directly set. @@ -1210,7 +1210,7 @@ The following table describes every entry of the `Input Parameters` column of th Boolean - If true, a dummy scroll-animation is performed _(no actual scroll takes place)_ to test the stepLengthCalculator.
+ If true, a dummy scroll-animation is performed (no actual scroll takes place) to test the stepLengthCalculator.
If false the new calculator is directly set. @@ -1264,7 +1264,7 @@ The following table describes every entry of the `Input Parameters` column of th Boolean - If true, a dummy scroll-animation is performed _(no actual scroll takes place)_ to test the stepLengthCalculator.
+ If true, a dummy scroll-animation is performed (no actual scroll takes place) to test the stepLengthCalculator.
If false the new calculator is directly set. From 640a2c74c47a079e47566fed5fc39c902beb16fd Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Tue, 17 May 2022 12:14:13 +0200 Subject: [PATCH 04/30] Update ConstantsAbout.md --- docs/ConstantsAbout.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/ConstantsAbout.md b/docs/ConstantsAbout.md index c51c0e7..ceb148e 100644 --- a/docs/ConstantsAbout.md +++ b/docs/ConstantsAbout.md @@ -18,7 +18,8 @@ Name | Type | Description `DEFAULT_XSTEP_LENGTH` | `Number` | The initial value of the `uss._xStepLength` variable: it represents the default number of pixels scrolled in a single scroll-animation's step on the x-axis.
It's **16px at 412px** of _(initial window's)_ width and **23px at 1920px** of _(initial window's)_ width. `DEFAULT_YSTEP_LENGTH` | `Number` | The initial value of the `uss._yStepLength` variable: it represents the default number of pixels scrolled in a single scroll-animation's step on the y-axis.
It's **38px at 789px** of _(initial window's)_ height and **22px at 1920px** of _(initial window's)_ height. `DEFAULT_MIN_ANIMATION_FRAMES` | `Number` | The initial value of the `uss._minAnimationFrame` variable: it represent the default lowest number of frames any scroll-animation should last if no [`StepLengthCalculator`](./FAQ.md#q-what-is-a-steplengthcalculator-) is set for a container.
It's **51 frames at 929px** of _(initial window's)_ height. -`DEFAULT_SCROLL_CALCULATOR_TEST_VALUE` | `Number` | The default number of pixel scrolled when testing a newStepLengthCalculator. +`DEFAULT_TEST_CALCULATOR_SCROLL_VALUE` | `Number` | The default number of pixel scrolled when testing a newStepLengthCalculator. +`DEFAULT_TEST_CALCULATOR_DURATION` | `Number` | The default number of milliseconds the test of a newStepLengthCalculator should last. `DEFAULT_PAGE_SCROLLER` | `Object` | The initial value of the `uss_pageScroller` variable: it represent the default value used when an API method requires the `container` input parameter but nothing is passed. `DEFAULT_ERROR_LOGGER` | `Function` | A function that logs the API error messages inside the browser's console. `DEFAULT_WARNING_LOGGER` | `Function` | A function that logs the API warning messages inside the browser's console. From 13eb7e4505f2cc303bf14601081fc59b8db90532 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Tue, 17 May 2022 12:15:41 +0200 Subject: [PATCH 05/30] Update FunctionsAbout.md --- docs/FunctionsAbout.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/FunctionsAbout.md b/docs/FunctionsAbout.md index 9e6395a..dbcf1ac 100644 --- a/docs/FunctionsAbout.md +++ b/docs/FunctionsAbout.md @@ -278,7 +278,7 @@ uss.scrollYBy(50, myContainer, () => console.log("Done"), false); newCalculator - + Sets the StepLengthCalculator for (the x-axis of) the passed container if compatible. @@ -305,7 +305,7 @@ uss.scrollYBy(50, myContainer, () => console.log("Done"), false); newCalculator - + Sets the StepLengthCalculator for (the y-axis of) the passed container if compatible. @@ -332,7 +332,7 @@ uss.scrollYBy(50, myContainer, () => console.log("Done"), false); newCalculator - + Sets the StepLengthCalculator for (both the y and x axes of) the passed container if compatible. From 593123d7f5ae994904588ea10c5097d592a9af55 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Tue, 17 May 2022 13:05:20 +0200 Subject: [PATCH 06/30] the user has now control of the testing phase of a stepLengthCalculator --- cypress/integration/x-axis-getters-tests.js | 4 +- cypress/integration/x-axis-scroll-tests.js | 21 ++-- cypress/integration/x-axis-setters-tests.js | 26 ++-- cypress/integration/y-axis-getters-tests.js | 4 +- cypress/integration/y-axis-scroll-tests.js | 19 +-- cypress/integration/y-axis-setters-tests.js | 26 ++-- js/universalsmoothscroll.js | 128 ++++++++++++++------ 7 files changed, 144 insertions(+), 84 deletions(-) diff --git a/cypress/integration/x-axis-getters-tests.js b/cypress/integration/x-axis-getters-tests.js index 5979a56..e73f22b 100644 --- a/cypress/integration/x-axis-getters-tests.js +++ b/cypress/integration/x-axis-getters-tests.js @@ -65,10 +65,10 @@ describe("getXStepLengthCalculator-Body", function() { uss._containersData = new Map(); expect(uss.getXStepLengthCalculator()).to.be.undefined; - uss.setXStepLengthCalculator(nonTempTestCalculator, uss.getPageScroller()); + uss.setXStepLengthCalculator(nonTempTestCalculator, uss.getPageScroller(), false, true); expect(uss.getXStepLengthCalculator()).to.equal(nonTempTestCalculator); - uss.setXStepLengthCalculator(tempTestCalculator, uss.getPageScroller(), true); + uss.setXStepLengthCalculator(tempTestCalculator, uss.getPageScroller(), true, true); expect(uss.getXStepLengthCalculator(uss.getPageScroller(), true)).to.equal(tempTestCalculator); return new Cypress.Promise(resolve => { diff --git a/cypress/integration/x-axis-scroll-tests.js b/cypress/integration/x-axis-scroll-tests.js index b50e9d5..744aa74 100644 --- a/cypress/integration/x-axis-scroll-tests.js +++ b/cypress/integration/x-axis-scroll-tests.js @@ -72,10 +72,11 @@ describe("scrollXTo-StoppedScrollingWhileAnimating-Body", function() { var uss; var _resolve; const _testCalculator = (i = 0) => { - return (remaning, originalTimestamp, currentTimestamp, total, currentYPosition, finalYPosition, container) => { - if(i++ < 10) return total / 10; - uss.stopScrollingX(); - _resolve(); + return (remaning, originalTimestamp, currentTimestamp, total, currentXPosition, finalXPosition, container) => { + if(!uss.isXscrolling()) return total; //testing phase of the setXStepLengthCalculator + i++; + if(i < 10) return total / 10; + uss.stopScrollingX(container, _resolve); } } it("Checks the scrollXTo method whenever a scroll animation is stopped inside a stepLengthCalculator", function(){ @@ -84,12 +85,12 @@ describe("scrollXTo-StoppedScrollingWhileAnimating-Body", function() { .then((win) => { uss = win.uss; uss._containersData = new Map(); - uss.setXStepLengthCalculator(_testCalculator()); - + + uss.setXStepLengthCalculator(_testCalculator(), uss.getPageScroller(), false, true); return new Cypress.Promise(resolve => { _resolve = resolve; uss.scrollXTo(100, uss.getPageScroller()); - }); + }); }).then(() => { bodyScrollLeftShouldToBe(90); }) @@ -147,7 +148,7 @@ describe("scrollXToBy-StillStart-False-ExtendedScrollingWhileAnimating-Body", fu .then((win) => { uss = win.uss; uss._containersData = new Map(); - uss.setXStepLengthCalculator(_testCalculator()); + uss.setXStepLengthCalculator(_testCalculator(), uss.getPageScroller(), false, true); return new Cypress.Promise(resolve => { _resolve = resolve; uss.scrollXTo(100, uss.getPageScroller()); @@ -174,7 +175,7 @@ describe("scrollXTo-scrollXTo-ReplaceScrollingWhileAnimating-Body", function() { .then((win) => { uss = win.uss; uss._containersData = new Map(); - uss.setXStepLengthCalculator(_testCalculator()); + uss.setXStepLengthCalculator(_testCalculator(), uss.getPageScroller(), false, true); return new Cypress.Promise(resolve => { _resolve = resolve; uss.scrollXTo(100, uss.getPageScroller()); @@ -248,7 +249,7 @@ describe("isXScrolling-StoppedScrollingWhileAnimating-Body", function() { uss = win.uss; uss._containersData = new Map(); expect(uss.isXscrolling()).to.be.false; - uss.setXStepLengthCalculator(_testCalculator()); + uss.setXStepLengthCalculator(_testCalculator(), uss.getPageScroller(), false, true); return new Cypress.Promise(resolve => { _resolve = resolve; uss.scrollXTo(100, uss.getPageScroller()); diff --git a/cypress/integration/x-axis-setters-tests.js b/cypress/integration/x-axis-setters-tests.js index cce08fe..967096d 100644 --- a/cypress/integration/x-axis-setters-tests.js +++ b/cypress/integration/x-axis-setters-tests.js @@ -13,6 +13,7 @@ describe("setXStepLengthCalculator-Body", function() { var _testCalculatorInvalidTypeNaN = () => {return NaN}; var _testCalculatorValidType1 = () => 10; var _testCalculatorValidType2 = () => 5; + var _testCalculatorValidType3 = () => 0.00000001; //valid but takes more than the default testing timeout it("Checks the setXStepLengthCalculator method", function(){ cy.visit(testSite) cy.window() @@ -21,32 +22,35 @@ describe("setXStepLengthCalculator-Body", function() { uss._containersData = new Map(); //test invalid stepLengthCalculators - uss.setXStepLengthCalculator(_testCalculatorInvalidTypeString, uss.getPageScroller(), false); + uss.setXStepLengthCalculator(_testCalculatorInvalidTypeString, uss.getPageScroller(), false, true); expect(uss.getXStepLengthCalculator(uss.getPageScroller(), false)).to.be.undefined; - uss.setXStepLengthCalculator(_testCalculatorInvalidTypeString, uss.getPageScroller(), true); + uss.setXStepLengthCalculator(_testCalculatorInvalidTypeString, uss.getPageScroller(), true, true); expect(uss.getXStepLengthCalculator(uss.getPageScroller(), true)).to.be.undefined; - uss.setXStepLengthCalculator(_testCalculatorInvalidTypeNaN, uss.getPageScroller(), false); + uss.setXStepLengthCalculator(_testCalculatorInvalidTypeNaN, uss.getPageScroller(), false, true); expect(uss.getXStepLengthCalculator(uss.getPageScroller(), false)).to.be.undefined; - uss.setXStepLengthCalculator(_testCalculatorInvalidTypeNaN, uss.getPageScroller(), true); + uss.setXStepLengthCalculator(_testCalculatorInvalidTypeNaN, uss.getPageScroller(), true, true); expect(uss.getXStepLengthCalculator(uss.getPageScroller(), true)).to.be.undefined; //test valid stepLengthCalculators - uss.setXStepLengthCalculator(_testCalculatorValidType2, uss.getPageScroller(), false); + uss.setXStepLengthCalculator(_testCalculatorValidType1, uss.getPageScroller(), false, true); + expect(uss.getXStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType1); + + uss.setXStepLengthCalculator(_testCalculatorValidType2, uss.getPageScroller(), false, true); expect(uss.getXStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType2); - uss.setXStepLengthCalculator(_testCalculatorValidType1, uss.getPageScroller(), false); - expect(uss.getXStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType1); + uss.setXStepLengthCalculator(_testCalculatorValidType3, uss.getPageScroller(), false, true); + expect(uss.getXStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType3); - uss.setXStepLengthCalculator(_testCalculatorValidType2, uss.getPageScroller(), true); + uss.setXStepLengthCalculator(_testCalculatorValidType2, uss.getPageScroller(), true, true); expect(uss.getXStepLengthCalculator(uss.getPageScroller(), true)).to.equal(_testCalculatorValidType2); uss.stopScrollingY(); - expect(uss.getXStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType1); + expect(uss.getXStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType3); - uss.setXStepLengthCalculator(_testCalculatorValidType2, uss.getPageScroller(), true); + uss.setXStepLengthCalculator(_testCalculatorValidType2, uss.getPageScroller(), true, true); expect(uss.getXStepLengthCalculator(uss.getPageScroller(), true)).to.equal(_testCalculatorValidType2); return new Cypress.Promise(resolve => { @@ -54,7 +58,7 @@ describe("setXStepLengthCalculator-Body", function() { }); }).then(() => { bodyScrollLeftShouldToBe(100); - expect(uss.getXStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType1); + expect(uss.getXStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType3); }) }) }) diff --git a/cypress/integration/y-axis-getters-tests.js b/cypress/integration/y-axis-getters-tests.js index feabf51..9956682 100644 --- a/cypress/integration/y-axis-getters-tests.js +++ b/cypress/integration/y-axis-getters-tests.js @@ -65,10 +65,10 @@ describe("getYStepLengthCalculator-Body", function() { uss._containersData = new Map(); expect(uss.getYStepLengthCalculator()).to.be.undefined; - uss.setYStepLengthCalculator(nonTempTestCalculator, uss.getPageScroller()); + uss.setYStepLengthCalculator(nonTempTestCalculator, uss.getPageScroller(), false, true); expect(uss.getYStepLengthCalculator()).to.equal(nonTempTestCalculator); - uss.setYStepLengthCalculator(tempTestCalculator, uss.getPageScroller(), true); + uss.setYStepLengthCalculator(tempTestCalculator, uss.getPageScroller(), true, true); expect(uss.getYStepLengthCalculator(uss.getPageScroller(), true)).to.equal(tempTestCalculator); return new Cypress.Promise(resolve => { diff --git a/cypress/integration/y-axis-scroll-tests.js b/cypress/integration/y-axis-scroll-tests.js index a7f77e3..9d11c74 100644 --- a/cypress/integration/y-axis-scroll-tests.js +++ b/cypress/integration/y-axis-scroll-tests.js @@ -73,9 +73,10 @@ describe("scrollYTo-StoppedScrollingWhileAnimating-Body", function() { var _resolve; const _testCalculator = (i = 0) => { return (remaning, originalTimestamp, currentTimestamp, total, currentYPosition, finalYPosition, container) => { - if(i++ < 10) return total / 10; - uss.stopScrollingY(); - _resolve(); + if(!uss.isYscrolling()) return total; //testing phase of the setYStepLengthCalculator + i++; + if(i < 10) return total / 10; + uss.stopScrollingY(container, _resolve); } } it("Checks the scrollYTo method whenever a scroll animation is stopped inside a stepLengthCalculator", function(){ @@ -84,12 +85,12 @@ describe("scrollYTo-StoppedScrollingWhileAnimating-Body", function() { .then((win) => { uss = win.uss; uss._containersData = new Map(); - uss.setYStepLengthCalculator(_testCalculator()); - + + uss.setYStepLengthCalculator(_testCalculator(), uss.getPageScroller(), false, true); return new Cypress.Promise(resolve => { _resolve = resolve; uss.scrollYTo(100, uss.getPageScroller()); - }); + }); }).then(() => { bodyScrollTopShouldToBe(90); }) @@ -147,7 +148,7 @@ describe("scrollYToBy-StillStart-False-ExtendedScrollingWhileAnimating-Body", fu .then((win) => { uss = win.uss; uss._containersData = new Map(); - uss.setYStepLengthCalculator(_testCalculator()); + uss.setYStepLengthCalculator(_testCalculator(), uss.getPageScroller(), false, true); return new Cypress.Promise(resolve => { _resolve = resolve; uss.scrollYTo(100, uss.getPageScroller()); @@ -174,7 +175,7 @@ describe("scrollYTo-scrollYTo-ReplaceScrollingWhileAnimating-Body", function() { .then((win) => { uss = win.uss; uss._containersData = new Map(); - uss.setYStepLengthCalculator(_testCalculator()); + uss.setYStepLengthCalculator(_testCalculator(), uss.getPageScroller(), false, true); return new Cypress.Promise(resolve => { _resolve = resolve; uss.scrollYTo(100, uss.getPageScroller()); @@ -248,7 +249,7 @@ describe("isYScrolling-StoppedScrollingWhileAnimating-Body", function() { uss = win.uss; uss._containersData = new Map(); expect(uss.isYscrolling()).to.be.false; - uss.setYStepLengthCalculator(_testCalculator()); + uss.setYStepLengthCalculator(_testCalculator(), uss.getPageScroller(), false, true); return new Cypress.Promise(resolve => { _resolve = resolve; uss.scrollYTo(100, uss.getPageScroller()); diff --git a/cypress/integration/y-axis-setters-tests.js b/cypress/integration/y-axis-setters-tests.js index ba6f8c9..008a093 100644 --- a/cypress/integration/y-axis-setters-tests.js +++ b/cypress/integration/y-axis-setters-tests.js @@ -13,6 +13,7 @@ describe("setYStepLengthCalculator-Body", function() { var _testCalculatorInvalidTypeNaN = () => {return NaN}; var _testCalculatorValidType1 = () => 10; var _testCalculatorValidType2 = () => 5; + var _testCalculatorValidType3 = () => 0.00000001; //valid but takes more than the default testing timeout it("Checks the setYStepLengthCalculator method", function(){ cy.visit(testSite) cy.window() @@ -21,32 +22,35 @@ describe("setYStepLengthCalculator-Body", function() { uss._containersData = new Map(); //test invalid stepLengthCalculators - uss.setYStepLengthCalculator(_testCalculatorInvalidTypeString, uss.getPageScroller(), false); + uss.setYStepLengthCalculator(_testCalculatorInvalidTypeString, uss.getPageScroller(), false, true); expect(uss.getYStepLengthCalculator(uss.getPageScroller(), false)).to.be.undefined; - uss.setYStepLengthCalculator(_testCalculatorInvalidTypeString, uss.getPageScroller(), true); + uss.setYStepLengthCalculator(_testCalculatorInvalidTypeString, uss.getPageScroller(), true, true); expect(uss.getYStepLengthCalculator(uss.getPageScroller(), true)).to.be.undefined; - uss.setYStepLengthCalculator(_testCalculatorInvalidTypeNaN, uss.getPageScroller(), false); + uss.setYStepLengthCalculator(_testCalculatorInvalidTypeNaN, uss.getPageScroller(), false, true); expect(uss.getYStepLengthCalculator(uss.getPageScroller(), false)).to.be.undefined; - uss.setYStepLengthCalculator(_testCalculatorInvalidTypeNaN, uss.getPageScroller(), true); + uss.setYStepLengthCalculator(_testCalculatorInvalidTypeNaN, uss.getPageScroller(), true, true); expect(uss.getYStepLengthCalculator(uss.getPageScroller(), true)).to.be.undefined; //test valid stepLengthCalculators - uss.setYStepLengthCalculator(_testCalculatorValidType2, uss.getPageScroller(), false); + uss.setYStepLengthCalculator(_testCalculatorValidType1, uss.getPageScroller(), false, true); + expect(uss.getYStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType1); + + uss.setYStepLengthCalculator(_testCalculatorValidType2, uss.getPageScroller(), false, true); expect(uss.getYStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType2); - uss.setYStepLengthCalculator(_testCalculatorValidType1, uss.getPageScroller(), false); - expect(uss.getYStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType1); + uss.setYStepLengthCalculator(_testCalculatorValidType3, uss.getPageScroller(), false, true); + expect(uss.getYStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType3); - uss.setYStepLengthCalculator(_testCalculatorValidType2, uss.getPageScroller(), true); + uss.setYStepLengthCalculator(_testCalculatorValidType2, uss.getPageScroller(), true, true); expect(uss.getYStepLengthCalculator(uss.getPageScroller(), true)).to.equal(_testCalculatorValidType2); uss.stopScrollingY(); - expect(uss.getYStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType1); + expect(uss.getYStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType3); - uss.setYStepLengthCalculator(_testCalculatorValidType2, uss.getPageScroller(), true); + uss.setYStepLengthCalculator(_testCalculatorValidType2, uss.getPageScroller(), true, true); expect(uss.getYStepLengthCalculator(uss.getPageScroller(), true)).to.equal(_testCalculatorValidType2); return new Cypress.Promise(resolve => { @@ -54,7 +58,7 @@ describe("setYStepLengthCalculator-Body", function() { }); }).then(() => { bodyScrollTopShouldToBe(100); - expect(uss.getYStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType1); + expect(uss.getYStepLengthCalculator(uss.getPageScroller(), false)).to.equal(_testCalculatorValidType3); }) }) }) diff --git a/js/universalsmoothscroll.js b/js/universalsmoothscroll.js index aa091e1..c82a529 100644 --- a/js/universalsmoothscroll.js +++ b/js/universalsmoothscroll.js @@ -146,7 +146,8 @@ const INITIAL_WINDOW_HEIGHT = window.innerHeight; const DEFAULT_XSTEP_LENGTH = 16 + 7 / 1508 * (INITIAL_WINDOW_WIDTH - 412); //16px at 412px of width && 23px at 1920px of width const DEFAULT_YSTEP_LENGTH = Math.max(1, Math.abs(38 - 20 / 140 * (INITIAL_WINDOW_HEIGHT - 789))); //38px at 789px of height && 22px at 1920px of height const DEFAULT_MIN_ANIMATION_FRAMES = INITIAL_WINDOW_HEIGHT / DEFAULT_YSTEP_LENGTH; //51 frames at 929px of height -const DEFAULT_SCROLL_CALCULATOR_TEST_VALUE = 100; +const DEFAULT_TEST_CALCULATOR_SCROLL_VALUE = 100; //in px +const DEFAULT_TEST_CALCULATOR_DURATION = 5000; //in ms const DEFAULT_PAGE_SCROLLER = window; const DEFAULT_ERROR_LOGGER = (functionName, expectedValue, receivedValue) => { if(/disabled/i.test(uss._debugMode)) return; @@ -298,7 +299,7 @@ var uss = { getPageScroller: () => uss._pageScroller, getReducedMotionState: () => uss._reducedMotion, getDebugMode: () => uss._debugMode, - setXStepLengthCalculator: (newCalculator, container = uss._pageScroller, isTemporary = false) => { + setXStepLengthCalculator: (newCalculator, container = uss._pageScroller, isTemporary = false, shouldBeTested = false) => { if(typeof newCalculator !== "function") { DEFAULT_ERROR_LOGGER("setXStepLengthCalculator", "the newCalculator to be a function", newCalculator); return; @@ -307,17 +308,34 @@ var uss = { DEFAULT_ERROR_LOGGER("setXStepLengthCalculator", "the container to be an HTMLElement or the Window", container); return; } - const _testResult = newCalculator(DEFAULT_SCROLL_CALCULATOR_TEST_VALUE, //remaningScrollAmount - 0, //originalTimestamp - 0, //currentTimestamp - DEFAULT_SCROLL_CALCULATOR_TEST_VALUE, //totalScrollAmount - 0, //currentXPosition - DEFAULT_SCROLL_CALCULATOR_TEST_VALUE, //finalXPosition - container //container - ); - if(!Number.isFinite(_testResult)) { - DEFAULT_ERROR_LOGGER("setXStepLengthCalculator", "the newCalculator to return a valid step value", _testResult); - return; + //If requested, a full scroll-animation is simulated to test newCalculator + if(shouldBeTested) { + const _originalTimestamp = performance.now(); + let _remaningScrollAmount = DEFAULT_TEST_CALCULATOR_SCROLL_VALUE; + let _currentTimestamp; + do { + _currentTimestamp = performance.now(); + const _testResult = newCalculator( + _remaningScrollAmount, //remaningScrollAmount + _originalTimestamp, //originalTimestamp + _currentTimestamp, //currentTimestamp + DEFAULT_TEST_CALCULATOR_SCROLL_VALUE, //totalScrollAmount + DEFAULT_TEST_CALCULATOR_SCROLL_VALUE - _remaningScrollAmount, //currentXPosition + DEFAULT_TEST_CALCULATOR_SCROLL_VALUE, //finalXPosition + container //container + ); + if(!Number.isFinite(_testResult)) { + DEFAULT_ERROR_LOGGER("setXStepLengthCalculator", "the newCalculator to return a valid step value", _testResult); + return; + } + _remaningScrollAmount -= _testResult; + } while(_remaningScrollAmount > 0 && _currentTimestamp - _originalTimestamp <= DEFAULT_TEST_CALCULATOR_DURATION); + //The passed stepLengthCalculator may have entered a loop + if(_currentTimestamp - _originalTimestamp > DEFAULT_TEST_CALCULATOR_DURATION) { + DEFAULT_WARNING_LOGGER(newCalculator.name || "the passed calculator", + "didn't complete the test scroll-animation within " + DEFAULT_TEST_CALCULATOR_DURATION + "ms", + false); + } } const _oldData = uss._containersData.get(container); const _containerData = _oldData || []; @@ -328,7 +346,7 @@ var uss = { } if(!_oldData) uss._containersData.set(container, _containerData); }, - setYStepLengthCalculator: (newCalculator, container = uss._pageScroller, isTemporary = false) => { + setYStepLengthCalculator: (newCalculator, container = uss._pageScroller, isTemporary = false, shouldBeTested = false) => { if(typeof newCalculator !== "function") { DEFAULT_ERROR_LOGGER("setYStepLengthCalculator", "the newCalculator to be a function", newCalculator); return; @@ -337,18 +355,34 @@ var uss = { DEFAULT_ERROR_LOGGER("setYStepLengthCalculator", "the container to be an HTMLElement or the Window", container); return; } - const _testResult = newCalculator(DEFAULT_SCROLL_CALCULATOR_TEST_VALUE, //remaningScrollAmount - 0, //originalTimestamp - 0, //currentTimestamp - DEFAULT_SCROLL_CALCULATOR_TEST_VALUE, //totalScrollAmount - 0, //currentYPosition - DEFAULT_SCROLL_CALCULATOR_TEST_VALUE, //finalYPosition - container //container - ); - - if(!Number.isFinite(_testResult)) { - DEFAULT_ERROR_LOGGER("setYStepLengthCalculator", "the newCalculator to return a valid step value", _testResult); - return; + //If requested, a full scroll-animation is simulated to test newCalculator + if(shouldBeTested) { + const _originalTimestamp = performance.now(); + let _remaningScrollAmount = DEFAULT_TEST_CALCULATOR_SCROLL_VALUE; + let _currentTimestamp; + do { + _currentTimestamp = performance.now(); + const _testResult = newCalculator( + _remaningScrollAmount, //remaningScrollAmount + _originalTimestamp, //originalTimestamp + _currentTimestamp, //currentTimestamp + DEFAULT_TEST_CALCULATOR_SCROLL_VALUE, //totalScrollAmount + DEFAULT_TEST_CALCULATOR_SCROLL_VALUE - _remaningScrollAmount, //currentXPosition + DEFAULT_TEST_CALCULATOR_SCROLL_VALUE, //finalXPosition + container //container + ); + if(!Number.isFinite(_testResult)) { + DEFAULT_ERROR_LOGGER("setYStepLengthCalculator", "the newCalculator to return a valid step value", _testResult); + return; + } + _remaningScrollAmount -= _testResult; + } while(_remaningScrollAmount > 0 && _currentTimestamp - _originalTimestamp <= DEFAULT_TEST_CALCULATOR_DURATION); + //The passed stepLengthCalculator may have entered a loop + if(_currentTimestamp - _originalTimestamp > DEFAULT_TEST_CALCULATOR_DURATION) { + DEFAULT_WARNING_LOGGER(newCalculator.name || "the passed calculator", + "didn't complete the test scroll-animation within " + DEFAULT_TEST_CALCULATOR_DURATION + "ms", + false); + } } const _oldData = uss._containersData.get(container); const _containerData = _oldData || []; @@ -359,7 +393,7 @@ var uss = { } if(!_oldData) uss._containersData.set(container, _containerData); }, - setStepLengthCalculator: (newCalculator, container = uss._pageScroller, isTemporary = false) => { + setStepLengthCalculator: (newCalculator, container = uss._pageScroller, isTemporary = false, shouldBeTested = false) => { if(typeof newCalculator !== "function") { DEFAULT_ERROR_LOGGER("setStepLengthCalculator", "the newCalculator to be a function", newCalculator); return; @@ -368,18 +402,34 @@ var uss = { DEFAULT_ERROR_LOGGER("setStepLengthCalculator", "the container to be an HTMLElement or the Window", container); return; } - const _testResult = newCalculator(DEFAULT_SCROLL_CALCULATOR_TEST_VALUE, //remaningScrollAmount - 0, //originalTimestamp - 0, //currentTimestamp - DEFAULT_SCROLL_CALCULATOR_TEST_VALUE, //totalScrollAmount - 0, //currentPosition - DEFAULT_SCROLL_CALCULATOR_TEST_VALUE, //finalPosition - container //container - ); - - if(!Number.isFinite(_testResult)) { - DEFAULT_ERROR_LOGGER("setStepLengthCalculator", "the newCalculator to return a valid step value", _testResult); - return; + //If requested, a full scroll-animation is simulated to test newCalculator + if(shouldBeTested) { + const _originalTimestamp = performance.now(); + let _remaningScrollAmount = DEFAULT_TEST_CALCULATOR_SCROLL_VALUE; + let _currentTimestamp; + do { + _currentTimestamp = performance.now(); + const _testResult = newCalculator( + _remaningScrollAmount, //remaningScrollAmount + _originalTimestamp, //originalTimestamp + _currentTimestamp, //currentTimestamp + DEFAULT_TEST_CALCULATOR_SCROLL_VALUE, //totalScrollAmount + DEFAULT_TEST_CALCULATOR_SCROLL_VALUE - _remaningScrollAmount, //currentXPosition + DEFAULT_TEST_CALCULATOR_SCROLL_VALUE, //finalXPosition + container //container + ); + if(!Number.isFinite(_testResult)) { + DEFAULT_ERROR_LOGGER("setStepLengthCalculator", "the newCalculator to return a valid step value", _testResult); + return; + } + _remaningScrollAmount -= _testResult; + } while(_remaningScrollAmount > 0 && _currentTimestamp - _originalTimestamp <= DEFAULT_TEST_CALCULATOR_DURATION); + //The passed stepLengthCalculator may have entered a loop + if(_currentTimestamp - _originalTimestamp > DEFAULT_TEST_CALCULATOR_DURATION) { + DEFAULT_WARNING_LOGGER(newCalculator.name || "the passed calculator", + "didn't complete the test scroll-animation within " + DEFAULT_TEST_CALCULATOR_DURATION + "ms", + false); + } } const _oldData = uss._containersData.get(container); const _containerData = _oldData || []; From d6f74ea6e243dad7b6e7f0964a5c32df5556f4ef Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Tue, 17 May 2022 15:56:28 +0200 Subject: [PATCH 07/30] Update universalsmoothscroll.js --- js/universalsmoothscroll.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/universalsmoothscroll.js b/js/universalsmoothscroll.js index c82a529..d406b4f 100644 --- a/js/universalsmoothscroll.js +++ b/js/universalsmoothscroll.js @@ -9,7 +9,8 @@ * It's 38px at 789px of (initial window's) height and 22px at 1920px of (initial window's) height. * DEFAULT_MIN_ANIMATION_FRAMES: number, The initial value of the `uss._minAnimationFrame` variable: * it represent the default lowest number of frames any scroll-animation should last if no StepLengthCalculator is set for a container. - * DEFAULT_SCROLL_CALCULATOR_TEST_VALUE: number, the default number of pixel scrolled when testing a newScrollCalculator. + * DEFAULT_TEST_CALCULATOR_SCROLL_VALUE: number, the default number of pixel scrolled when testing a newScrollCalculator. + * DEFAULT_TEST_CALCULATOR_DURATION: number, the default number of milliseconds the test of a newStepLengthCalculator should last. * DEFAULT_PAGE_SCROLLER: object, the initial value of the uss_pageScroller variable: * it represent the default value used when an API method requires the "container" input parameter but nothing is passed. * DEFAULT_ERROR_LOGGER: function, logs the API error messages inside the browser's console. From 0c4c703c69a0efa5a0427f83e1712266d190471a Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Tue, 17 May 2022 16:09:04 +0200 Subject: [PATCH 08/30] test commit --- js/universalsmoothscroll.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/universalsmoothscroll.js b/js/universalsmoothscroll.js index d406b4f..b2a6059 100644 --- a/js/universalsmoothscroll.js +++ b/js/universalsmoothscroll.js @@ -1320,8 +1320,10 @@ var uss = { _alignToTop === true ? _bordersDimensions[0] : _alignToTop === false ? _containerHeight - _elementHeight - _scrollbarsDimensions[1] - _bordersDimensions[2] : (_containerHeight - _elementHeight - _scrollbarsDimensions[1] - _bordersDimensions[2] + _bordersDimensions[0]) * 0.5; + const _deltaX = _elementInitialX - _elementFinalX; const _deltaY = _elementInitialY - _elementFinalY; + const _callback = () => { if(_currentElement === element) { if(typeof callback === "function") callback(); From c9d41339e235b8cdd02897608bf35d4590a6b89b Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 11:01:39 +0200 Subject: [PATCH 09/30] adding test to beta --- .github/workflows/uss_ubuntu_tests.yml | 71 +++++++++++++++++++++++++ .github/workflows/uss_windows_tests.yml | 70 ++++++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 .github/workflows/uss_ubuntu_tests.yml create mode 100644 .github/workflows/uss_windows_tests.yml diff --git a/.github/workflows/uss_ubuntu_tests.yml b/.github/workflows/uss_ubuntu_tests.yml new file mode 100644 index 0000000..d3b2168 --- /dev/null +++ b/.github/workflows/uss_ubuntu_tests.yml @@ -0,0 +1,71 @@ +name: uss-tests-ubuntu + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events for beta and master branches + push: + pull_request: + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + chrome-test: + # The type of runner that the job will run on + runs-on: ubuntu-latest + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout + uses: actions/checkout@v3 + #workaround for creating the package.json file + - name: Setup npm package + run: npm init -y && npm install + # Runs a single command using the runners shell + - name: Cypress run + uses: cypress-io/github-action@v2 + with: + build: npm i -D cypress + browser: chrome + + firefox-test: + # The type of runner that the job will run on + runs-on: ubuntu-latest + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout + uses: actions/checkout@v3 + #workaround for creating the package.json file + - name: Setup npm package + run: npm init -y && npm install + # Runs a single command using the runners shell + - name: Cypress run + uses: cypress-io/github-action@v2 + with: + build: npm i -D cypress + browser: firefox + +#not available yet +# edge-test: +# # The type of runner that the job will run on +# runs-on: ubuntu-latest +# # Steps represent a sequence of tasks that will be executed as part of the job +# steps: +# # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it +# - name: Checkout +# uses: actions/checkout@v3 +# #workaround for creating the package.json file +# - name: Setup npm package +# run: npm init -y && npm install +# #install edge +# - uses: browser-actions/setup-edge@latest +# - name: Print Edge version +# run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion +# # Runs a single command using the runners shell +# - name: Cypress run +# uses: cypress-io/github-action@v2 +# with: +# build: npm i -D cypress +# browser: edge diff --git a/.github/workflows/uss_windows_tests.yml b/.github/workflows/uss_windows_tests.yml new file mode 100644 index 0000000..561b687 --- /dev/null +++ b/.github/workflows/uss_windows_tests.yml @@ -0,0 +1,70 @@ +name: uss-tests-windows + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events for beta and master branches + push: + pull_request: + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + chrome-test: + # The type of runner that the job will run on + runs-on: windows-latest + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout + uses: actions/checkout@v3 + #workaround for creating the package.json file + - name: Setup npm package + run: npm init -y && npm install + # Runs a single command using the runners shell + - name: Cypress run + uses: cypress-io/github-action@v2 + with: + build: npm i -D cypress + browser: chrome + + firefox-test: + # The type of runner that the job will run on + runs-on: windows-latest + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout + uses: actions/checkout@v3 + #workaround for creating the package.json file + - name: Setup npm package + run: npm init -y && npm install + # Runs a single command using the runners shell + - name: Cypress run + uses: cypress-io/github-action@v2 + with: + build: npm i -D cypress + browser: firefox + + edge-test: + # The type of runner that the job will run on + runs-on: windows-latest + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout + uses: actions/checkout@v3 + #workaround for creating the package.json file + - name: Setup npm package + run: npm init -y && npm install + #install edge + - uses: browser-actions/setup-edge@latest + - name: Print Edge version + run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion + # Runs a single command using the runners shell + - name: Cypress run + uses: cypress-io/github-action@v2 + with: + build: npm i -D cypress + browser: edge \ No newline at end of file From 322000990748f03fe8016d6a25b00c1ccad56682 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 11:05:37 +0200 Subject: [PATCH 10/30] Update cypress.json --- cypress.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cypress.json b/cypress.json index c8e0ed1..8eed093 100644 --- a/cypress.json +++ b/cypress.json @@ -1,5 +1,6 @@ { "env": { - "testSite": "http://192.168.178.32:8080/" + "testSite": "https://cristiandavideconte.github.io/universalSmoothScroll/" , + "preferredTimeout": 15000 } } From 890858dfcb104ed7465da6016293bae25b4e32a3 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 11:17:26 +0200 Subject: [PATCH 11/30] updated tests --- .github/workflows/uss_ubuntu_tests.yml | 23 +++++++++++++++++++---- .github/workflows/uss_windows_tests.yml | 23 +++++++++++++++++++---- cypress.json | 2 +- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/.github/workflows/uss_ubuntu_tests.yml b/.github/workflows/uss_ubuntu_tests.yml index d3b2168..dcaebba 100644 --- a/.github/workflows/uss_ubuntu_tests.yml +++ b/.github/workflows/uss_ubuntu_tests.yml @@ -19,9 +19,14 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout uses: actions/checkout@v3 - #workaround for creating the package.json file + # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install + # Installs and open a local http-server to serve the tests' index file + - name: Setup http-server + run: | + npm install --global http-server + http-server # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 @@ -37,9 +42,14 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout uses: actions/checkout@v3 - #workaround for creating the package.json file + # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install + # Installs and open a local http-server to serve the tests' index file + - name: Setup http-server + run: | + npm install --global http-server + http-server # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 @@ -56,13 +66,18 @@ jobs: # # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it # - name: Checkout # uses: actions/checkout@v3 -# #workaround for creating the package.json file +# # Workaround for creating the package.json file # - name: Setup npm package # run: npm init -y && npm install -# #install edge +# # Installs edge # - uses: browser-actions/setup-edge@latest # - name: Print Edge version # run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion +# # Installs and open a local http-server to serve the tests' index file +# - name: Setup http-server +# run: | +# npm install --global http-server +# http-server # # Runs a single command using the runners shell # - name: Cypress run # uses: cypress-io/github-action@v2 diff --git a/.github/workflows/uss_windows_tests.yml b/.github/workflows/uss_windows_tests.yml index 561b687..4759615 100644 --- a/.github/workflows/uss_windows_tests.yml +++ b/.github/workflows/uss_windows_tests.yml @@ -19,9 +19,14 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout uses: actions/checkout@v3 - #workaround for creating the package.json file + # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install + # Installs and open a local http-server to serve the tests' index file + - name: Setup http-server + run: | + npm install --global http-server + http-server # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 @@ -37,9 +42,14 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout uses: actions/checkout@v3 - #workaround for creating the package.json file + # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install + # Installs and open a local http-server to serve the tests' index file + - name: Setup http-server + run: | + npm install --global http-server + http-server # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 @@ -55,13 +65,18 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout uses: actions/checkout@v3 - #workaround for creating the package.json file + # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install - #install edge + # Installs edge - uses: browser-actions/setup-edge@latest - name: Print Edge version run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion + # Installs and open a local http-server to serve the tests' index file + - name: Setup http-server + run: | + npm install --global http-server + http-server # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 diff --git a/cypress.json b/cypress.json index 8eed093..b1352f7 100644 --- a/cypress.json +++ b/cypress.json @@ -1,6 +1,6 @@ { "env": { - "testSite": "https://cristiandavideconte.github.io/universalSmoothScroll/" , + "testSite": "http://192.168.178.32:8080/", "preferredTimeout": 15000 } } From f3d14c76687e4848533b00a4ba3f03918cf10e77 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 11:25:18 +0200 Subject: [PATCH 12/30] removed global installation for http-server npm package --- .github/workflows/uss_ubuntu_tests.yml | 6 +++--- .github/workflows/uss_windows_tests.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/uss_ubuntu_tests.yml b/.github/workflows/uss_ubuntu_tests.yml index dcaebba..403ab0e 100644 --- a/.github/workflows/uss_ubuntu_tests.yml +++ b/.github/workflows/uss_ubuntu_tests.yml @@ -25,7 +25,7 @@ jobs: # Installs and open a local http-server to serve the tests' index file - name: Setup http-server run: | - npm install --global http-server + npm install http-server http-server # Runs a single command using the runners shell - name: Cypress run @@ -48,7 +48,7 @@ jobs: # Installs and open a local http-server to serve the tests' index file - name: Setup http-server run: | - npm install --global http-server + npm install http-server http-server # Runs a single command using the runners shell - name: Cypress run @@ -76,7 +76,7 @@ jobs: # # Installs and open a local http-server to serve the tests' index file # - name: Setup http-server # run: | -# npm install --global http-server +# npm install http-server # http-server # # Runs a single command using the runners shell # - name: Cypress run diff --git a/.github/workflows/uss_windows_tests.yml b/.github/workflows/uss_windows_tests.yml index 4759615..2fa6522 100644 --- a/.github/workflows/uss_windows_tests.yml +++ b/.github/workflows/uss_windows_tests.yml @@ -25,7 +25,7 @@ jobs: # Installs and open a local http-server to serve the tests' index file - name: Setup http-server run: | - npm install --global http-server + npm install http-server http-server # Runs a single command using the runners shell - name: Cypress run @@ -48,7 +48,7 @@ jobs: # Installs and open a local http-server to serve the tests' index file - name: Setup http-server run: | - npm install --global http-server + npm install http-server http-server # Runs a single command using the runners shell - name: Cypress run @@ -75,7 +75,7 @@ jobs: # Installs and open a local http-server to serve the tests' index file - name: Setup http-server run: | - npm install --global http-server + npm install http-server http-server # Runs a single command using the runners shell - name: Cypress run From 4f398105bc8f284302393e6d4b72fc338da47bf1 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 11:30:54 +0200 Subject: [PATCH 13/30] updated tests --- .github/workflows/uss_ubuntu_tests.yml | 12 ++++++------ .github/workflows/uss_windows_tests.yml | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/uss_ubuntu_tests.yml b/.github/workflows/uss_ubuntu_tests.yml index 403ab0e..0036961 100644 --- a/.github/workflows/uss_ubuntu_tests.yml +++ b/.github/workflows/uss_ubuntu_tests.yml @@ -25,8 +25,8 @@ jobs: # Installs and open a local http-server to serve the tests' index file - name: Setup http-server run: | - npm install http-server - http-server + npm install --global http-server + http-server & # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 @@ -48,8 +48,8 @@ jobs: # Installs and open a local http-server to serve the tests' index file - name: Setup http-server run: | - npm install http-server - http-server + npm install --global http-server + http-server & # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 @@ -76,8 +76,8 @@ jobs: # # Installs and open a local http-server to serve the tests' index file # - name: Setup http-server # run: | -# npm install http-server -# http-server +# npm install --global http-server +# http-server & # # Runs a single command using the runners shell # - name: Cypress run # uses: cypress-io/github-action@v2 diff --git a/.github/workflows/uss_windows_tests.yml b/.github/workflows/uss_windows_tests.yml index 2fa6522..c910424 100644 --- a/.github/workflows/uss_windows_tests.yml +++ b/.github/workflows/uss_windows_tests.yml @@ -25,8 +25,8 @@ jobs: # Installs and open a local http-server to serve the tests' index file - name: Setup http-server run: | - npm install http-server - http-server + npm install --global http-server + START /B http-server # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 @@ -48,8 +48,8 @@ jobs: # Installs and open a local http-server to serve the tests' index file - name: Setup http-server run: | - npm install http-server - http-server + npm install --global http-server + START /B http-server # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 @@ -75,8 +75,8 @@ jobs: # Installs and open a local http-server to serve the tests' index file - name: Setup http-server run: | - npm install http-server - http-server + npm install --global http-server + START /B http-server # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 From 46bb671466839ae425f55b9d168154000d87422d Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 11:32:53 +0200 Subject: [PATCH 14/30] Update cypress.json --- cypress.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress.json b/cypress.json index b1352f7..e289023 100644 --- a/cypress.json +++ b/cypress.json @@ -1,6 +1,6 @@ { "env": { - "testSite": "http://192.168.178.32:8080/", + "testSite": "http://127.0.0.1:8080/", "preferredTimeout": 15000 } } From 0b36c1cb9ae6268f19d954e73221367ac2c045a8 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 11:47:41 +0200 Subject: [PATCH 15/30] switched to cypress background server for tests' hosting --- .github/workflows/uss_ubuntu_tests.yml | 21 +++----- .github/workflows/uss_windows_tests.yml | 66 +++++++++++-------------- 2 files changed, 35 insertions(+), 52 deletions(-) diff --git a/.github/workflows/uss_ubuntu_tests.yml b/.github/workflows/uss_ubuntu_tests.yml index 0036961..33b10c5 100644 --- a/.github/workflows/uss_ubuntu_tests.yml +++ b/.github/workflows/uss_ubuntu_tests.yml @@ -22,15 +22,12 @@ jobs: # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install - # Installs and open a local http-server to serve the tests' index file - - name: Setup http-server - run: | - npm install --global http-server - http-server & # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 with: + start: npm start + wait-on: "http://localhost:8080" build: npm i -D cypress browser: chrome @@ -45,15 +42,12 @@ jobs: # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install - # Installs and open a local http-server to serve the tests' index file - - name: Setup http-server - run: | - npm install --global http-server - http-server & # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 with: + start: npm start + wait-on: "http://localhost:8080" build: npm i -D cypress browser: firefox @@ -73,14 +67,11 @@ jobs: # - uses: browser-actions/setup-edge@latest # - name: Print Edge version # run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion -# # Installs and open a local http-server to serve the tests' index file -# - name: Setup http-server -# run: | -# npm install --global http-server -# http-server & # # Runs a single command using the runners shell # - name: Cypress run # uses: cypress-io/github-action@v2 # with: +# start: npm start +# wait-on: "http://localhost:8080" # build: npm i -D cypress # browser: edge diff --git a/.github/workflows/uss_windows_tests.yml b/.github/workflows/uss_windows_tests.yml index c910424..114fd22 100644 --- a/.github/workflows/uss_windows_tests.yml +++ b/.github/workflows/uss_windows_tests.yml @@ -22,15 +22,12 @@ jobs: # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install - # Installs and open a local http-server to serve the tests' index file - - name: Setup http-server - run: | - npm install --global http-server - START /B http-server # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 with: + start-windows: npm start + wait-on: "http://localhost:8080" build: npm i -D cypress browser: chrome @@ -45,41 +42,36 @@ jobs: # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install - # Installs and open a local http-server to serve the tests' index file - - name: Setup http-server - run: | - npm install --global http-server - START /B http-server # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 with: + start-windows: npm start + wait-on: "http://localhost:8080" build: npm i -D cypress browser: firefox - - edge-test: - # The type of runner that the job will run on - runs-on: windows-latest - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - name: Checkout - uses: actions/checkout@v3 - # Workaround for creating the package.json file - - name: Setup npm package - run: npm init -y && npm install - # Installs edge - - uses: browser-actions/setup-edge@latest - - name: Print Edge version - run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion - # Installs and open a local http-server to serve the tests' index file - - name: Setup http-server - run: | - npm install --global http-server - START /B http-server - # Runs a single command using the runners shell - - name: Cypress run - uses: cypress-io/github-action@v2 - with: - build: npm i -D cypress - browser: edge \ No newline at end of file + +#not available yet +# edge-test: +# # The type of runner that the job will run on +# runs-on: windows-latest +# # Steps represent a sequence of tasks that will be executed as part of the job +# steps: +# # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it +# - name: Checkout +# uses: actions/checkout@v3 +# # Workaround for creating the package.json file +# - name: Setup npm package +# run: npm init -y && npm install +# # Installs edge +# - uses: browser-actions/setup-edge@latest +# - name: Print Edge version +# run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion +# # Runs a single command using the runners shell +# - name: Cypress run +# uses: cypress-io/github-action@v2 +# with: +# start-windows: npm start +# wait-on: "http://localhost:8080" +# build: npm i -D cypress +# browser: edge From 246440a4cc5cb08d047500fa9c7a593c93533b7d Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 12:04:30 +0200 Subject: [PATCH 16/30] updated tests --- .github/workflows/uss_ubuntu_tests.yml | 4 +- .github/workflows/uss_windows_tests.yml | 51 +++++++++++++------------ 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/.github/workflows/uss_ubuntu_tests.yml b/.github/workflows/uss_ubuntu_tests.yml index 33b10c5..5bc1f87 100644 --- a/.github/workflows/uss_ubuntu_tests.yml +++ b/.github/workflows/uss_ubuntu_tests.yml @@ -22,11 +22,13 @@ jobs: # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install + # Install and start the localhost server in the background + - name: Run server + run: npx http-server -c-1 & # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 with: - start: npm start wait-on: "http://localhost:8080" build: npm i -D cypress browser: chrome diff --git a/.github/workflows/uss_windows_tests.yml b/.github/workflows/uss_windows_tests.yml index 114fd22..59a3d6d 100644 --- a/.github/workflows/uss_windows_tests.yml +++ b/.github/workflows/uss_windows_tests.yml @@ -22,11 +22,13 @@ jobs: # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install + # Install and start the localhost server in the background + - name: Run server + run: npx http-server -c-1 & # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 with: - start-windows: npm start wait-on: "http://localhost:8080" build: npm i -D cypress browser: chrome @@ -51,27 +53,26 @@ jobs: build: npm i -D cypress browser: firefox -#not available yet -# edge-test: -# # The type of runner that the job will run on -# runs-on: windows-latest -# # Steps represent a sequence of tasks that will be executed as part of the job -# steps: -# # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it -# - name: Checkout -# uses: actions/checkout@v3 -# # Workaround for creating the package.json file -# - name: Setup npm package -# run: npm init -y && npm install -# # Installs edge -# - uses: browser-actions/setup-edge@latest -# - name: Print Edge version -# run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion -# # Runs a single command using the runners shell -# - name: Cypress run -# uses: cypress-io/github-action@v2 -# with: -# start-windows: npm start -# wait-on: "http://localhost:8080" -# build: npm i -D cypress -# browser: edge + edge-test: + # The type of runner that the job will run on + runs-on: windows-latest + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout + uses: actions/checkout@v3 + # Workaround for creating the package.json file + - name: Setup npm package + run: npm init -y && npm install + # Installs edge + - uses: browser-actions/setup-edge@latest + - name: Print Edge version + run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion + # Runs a single command using the runners shell + - name: Cypress run + uses: cypress-io/github-action@v2 + with: + start-windows: npm start + wait-on: "http://localhost:8080" + build: npm i -D cypress + browser: edge From aceecee7ede680da016bf115c4095d406ca8f462 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 12:09:53 +0200 Subject: [PATCH 17/30] switched to npx for test-localhosting --- .github/workflows/uss_ubuntu_tests.yml | 11 ++++++----- .github/workflows/uss_windows_tests.yml | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/uss_ubuntu_tests.yml b/.github/workflows/uss_ubuntu_tests.yml index 5bc1f87..1dd258b 100644 --- a/.github/workflows/uss_ubuntu_tests.yml +++ b/.github/workflows/uss_ubuntu_tests.yml @@ -29,7 +29,6 @@ jobs: - name: Cypress run uses: cypress-io/github-action@v2 with: - wait-on: "http://localhost:8080" build: npm i -D cypress browser: chrome @@ -44,12 +43,13 @@ jobs: # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install + # Install and start the localhost server in the background + - name: Run server + run: npx http-server -c-1 & # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 with: - start: npm start - wait-on: "http://localhost:8080" build: npm i -D cypress browser: firefox @@ -69,11 +69,12 @@ jobs: # - uses: browser-actions/setup-edge@latest # - name: Print Edge version # run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion +# # Install and start the localhost server in the background +# - name: Run server +# run: npx http-server -c-1 & # # Runs a single command using the runners shell # - name: Cypress run # uses: cypress-io/github-action@v2 # with: -# start: npm start -# wait-on: "http://localhost:8080" # build: npm i -D cypress # browser: edge diff --git a/.github/workflows/uss_windows_tests.yml b/.github/workflows/uss_windows_tests.yml index 59a3d6d..da39afa 100644 --- a/.github/workflows/uss_windows_tests.yml +++ b/.github/workflows/uss_windows_tests.yml @@ -29,7 +29,6 @@ jobs: - name: Cypress run uses: cypress-io/github-action@v2 with: - wait-on: "http://localhost:8080" build: npm i -D cypress browser: chrome @@ -44,12 +43,13 @@ jobs: # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install + # Install and start the localhost server in the background + - name: Run server + run: npx http-server -c-1 & # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 with: - start-windows: npm start - wait-on: "http://localhost:8080" build: npm i -D cypress browser: firefox @@ -68,11 +68,12 @@ jobs: - uses: browser-actions/setup-edge@latest - name: Print Edge version run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion + # Install and start the localhost server in the background + - name: Run server + run: npx http-server -c-1 & # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 with: - start-windows: npm start - wait-on: "http://localhost:8080" build: npm i -D cypress browser: edge From ff6d8d710ee731f64a8bc438b337b4c4fe54e159 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 12:29:58 +0200 Subject: [PATCH 18/30] updated tests --- .github/workflows/uss_windows_tests.yml | 2 +- cypress.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/uss_windows_tests.yml b/.github/workflows/uss_windows_tests.yml index da39afa..0b5fcc7 100644 --- a/.github/workflows/uss_windows_tests.yml +++ b/.github/workflows/uss_windows_tests.yml @@ -24,7 +24,7 @@ jobs: run: npm init -y && npm install # Install and start the localhost server in the background - name: Run server - run: npx http-server -c-1 & + run: npx http-server & # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 diff --git a/cypress.json b/cypress.json index e289023..1baecc1 100644 --- a/cypress.json +++ b/cypress.json @@ -1,6 +1,6 @@ { "env": { "testSite": "http://127.0.0.1:8080/", - "preferredTimeout": 15000 + "preferredTimeout": 4000 } } From f93dba644e8ca2aad54d237f9e7ff4c2c1c71921 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 12:49:10 +0200 Subject: [PATCH 19/30] updated tests --- .github/workflows/uss_ubuntu_tests.yml | 3 +++ .github/workflows/uss_windows_tests.yml | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/uss_ubuntu_tests.yml b/.github/workflows/uss_ubuntu_tests.yml index 1dd258b..609d524 100644 --- a/.github/workflows/uss_ubuntu_tests.yml +++ b/.github/workflows/uss_ubuntu_tests.yml @@ -29,6 +29,7 @@ jobs: - name: Cypress run uses: cypress-io/github-action@v2 with: + wait-on: "http://localhost:8080" build: npm i -D cypress browser: chrome @@ -50,6 +51,7 @@ jobs: - name: Cypress run uses: cypress-io/github-action@v2 with: + wait-on: "http://localhost:8080" build: npm i -D cypress browser: firefox @@ -76,5 +78,6 @@ jobs: # - name: Cypress run # uses: cypress-io/github-action@v2 # with: +# wait-on: "http://localhost:8080" # build: npm i -D cypress # browser: edge diff --git a/.github/workflows/uss_windows_tests.yml b/.github/workflows/uss_windows_tests.yml index 0b5fcc7..8d760e0 100644 --- a/.github/workflows/uss_windows_tests.yml +++ b/.github/workflows/uss_windows_tests.yml @@ -24,11 +24,12 @@ jobs: run: npm init -y && npm install # Install and start the localhost server in the background - name: Run server - run: npx http-server & + run: npx http-server -c-1 & # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 with: + wait-on: "http://localhost:8080" build: npm i -D cypress browser: chrome @@ -50,6 +51,7 @@ jobs: - name: Cypress run uses: cypress-io/github-action@v2 with: + wait-on: "http://localhost:8080" build: npm i -D cypress browser: firefox @@ -75,5 +77,6 @@ jobs: - name: Cypress run uses: cypress-io/github-action@v2 with: + wait-on: "http://localhost:8080" build: npm i -D cypress browser: edge From c79ce677f810f26e1c8f3b47a740eb7202e5330f Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 13:14:04 +0200 Subject: [PATCH 20/30] Update uss_windows_tests.yml --- .github/workflows/uss_windows_tests.yml | 27 ++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/uss_windows_tests.yml b/.github/workflows/uss_windows_tests.yml index 8d760e0..a3409ad 100644 --- a/.github/workflows/uss_windows_tests.yml +++ b/.github/workflows/uss_windows_tests.yml @@ -22,9 +22,30 @@ jobs: # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install - # Install and start the localhost server in the background - - name: Run server - run: npx http-server -c-1 & + # Install the localhost server + - name: Serve Files + uses: Eun/http-server-action@v1 + with: + directory: ${{ github.workspace }} + port: 8080 + no-cache: false + content-types: | + { + "appcache": "text/cache-manifest", + "css": "text/css", + "gif": "image/gif", + "html": "text/html", + "ico": "image/x-icon", + "jpeg": "image/jpeg", + "jpg": "image/jpeg", + "js": "text/javascript", + "json": "application/json", + "png": "image/png", + "txt": "text/plain", + "xml": "text/xml" + } + # Run the localhost server in background + - run: curl -vvvv http://localhost:8080/index.html # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 From a9a12b64240eceb2405f6f4cc26771303254af7a Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 19:34:38 +0200 Subject: [PATCH 21/30] Update FAQ.md --- docs/FAQ.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/docs/FAQ.md b/docs/FAQ.md index d713325..349e44e 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -86,7 +86,8 @@ A: Yes, you can create a custom [`StepLengthCalculator`](./FAQ.md#q-what-is-a-st For example:
```javascript uss.setYStepLengthCalculator( - (remaning, originalTimestamp, timestamp, total, currentY, finalY, container) => { //A custom StepLengthCalculator + //This function is a custom StepLengthCalculator + (remaning, originalTimestamp, timestamp, total, currentY, finalY, container) => { return remaning / 15 + 1; } ); @@ -154,8 +155,11 @@ const myStepLengthCalculator = (remaning, originalTimestamp, currentTimestamp, t return traveledDistance + 1; //+1 because at first traveledDistance = 0 and we would never start moving without it }; -//myStepLengthCalculator will controll only the easing on the y axis of myContainer -uss.setYStepLengthCalculator(myStepLengthCalculator, myContainer); +//myStepLengthCalculator: +//- will controll only the easing on the y axis of myContainer (first 2 parameters) +//- it won't be discarded after just one animation (3rd parameter) +//- it won't be tested by the API because we know it works (4th parameter) +uss.setYStepLengthCalculator(myStepLengthCalculator, myContainer, false, false); ```
@@ -174,6 +178,49 @@ uss.setXStepLengthCalculator(EASE_OUT_CUBIC(1000), myContainer); ```
+If you're not sure to have a valid StepLengthCalculator just ask the API to test it for you with the [`shouldBeTested`](./FunctionsAbout.md#setXStepLengthCalculator) parameter.
+ +E.g.:
+```javascript +/* + * This StepLengthCalculator won't return a valid stepLength after + * the value of i is greater than 10. + * Unfortunately we didn't catch this bug at first. + */ +const myBrokenCalculator = (i = 0) => { + if(i++ <= 10) return 50; +} +const isTemporary = false; +const shouldBeTested = true; + +/* + * Since we set the shouldBeTested paramenter to true, the API will test our StepLengthCalculator with a + * dummy scroll-animation (no scroll actually takes place) and at the end of it, + * an error message that informs us that myBrokenCalculator didn't return a valid stepLength will be printed in the console. + * Thus the StepLengthCalculator won't be set for now. + */ +uss.setXStepLengthCalculator(myBrokenCalculator, myContainer, isTemporary, shouldBeTested); + +const myPerfectlyWorkingCalculator = (i = 0) => { + if(i++ <= 10) return 50; + i = 0; + return 49; +} +/** + * Once our StepLengthCalculator is fixed we can tell the API to trust us and not test it anymore. + */ +uss.setXStepLengthCalculator(myBrokenCalculator, myContainer, isTemporary, false); + + +/* + * Keeping to true the shouldBeTested parameter will force the API to test the StepLengthCalculator. + * In the example below the setXStepLengthCalculator method will take 3seconds to complete instead of 1ms + * because it's waiting the EASE_LINEAR method to complete the test dummy scroll-animation. + */ +uss.setXStepLengthCalculator(EASE_LINEAR(3000), myContainer, isTemporary, true); +``` +
+ On [`easings.net`](https://easings.net/) you can find out more about the way the StepLengthCalculators provided by [`universalsmoothscroll-ease-functions`](./Download.md) library will affect your scroll-animations. --- @@ -187,7 +234,7 @@ _`stillStart = false`_ means that even if other scroll-animations on the same ax This is an example of how different these 2 kind of scroll-animations are:
```javascript const ourEaseFunction = (remaning) => {return remaning / 15 + 1;}; -uss.setYStepLengthCalculator(ourEaseFunction, myContainer); +uss.setYStepLengthCalculator(ourEaseFunction, myContainer, false, false); //CASE A: stillStart = true const stillStartTrueBehavior = wheelEvent => { From 69e13e12da2991c40dfbc7dbb75a018fc353e255 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 22:52:00 +0200 Subject: [PATCH 22/30] Update uss_windows_tests.yml --- .github/workflows/uss_windows_tests.yml | 30 +++++-------------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/.github/workflows/uss_windows_tests.yml b/.github/workflows/uss_windows_tests.yml index a3409ad..f2842f4 100644 --- a/.github/workflows/uss_windows_tests.yml +++ b/.github/workflows/uss_windows_tests.yml @@ -22,30 +22,12 @@ jobs: # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install - # Install the localhost server - - name: Serve Files - uses: Eun/http-server-action@v1 - with: - directory: ${{ github.workspace }} - port: 8080 - no-cache: false - content-types: | - { - "appcache": "text/cache-manifest", - "css": "text/css", - "gif": "image/gif", - "html": "text/html", - "ico": "image/x-icon", - "jpeg": "image/jpeg", - "jpg": "image/jpeg", - "js": "text/javascript", - "json": "application/json", - "png": "image/png", - "txt": "text/plain", - "xml": "text/xml" - } - # Run the localhost server in background - - run: curl -vvvv http://localhost:8080/index.html + # Installs the localhost server + - name: Install Server + run: npm install --global http-server + # Runs the locahost server + - name: Start server + run: http-server & # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 From 2f9ba0daf22e4398ebbd3e016e18bc4b633d6d6a Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 23:01:39 +0200 Subject: [PATCH 23/30] Update uss_windows_tests.yml --- .github/workflows/uss_windows_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/uss_windows_tests.yml b/.github/workflows/uss_windows_tests.yml index f2842f4..347e648 100644 --- a/.github/workflows/uss_windows_tests.yml +++ b/.github/workflows/uss_windows_tests.yml @@ -27,7 +27,7 @@ jobs: run: npm install --global http-server # Runs the locahost server - name: Start server - run: http-server & + run: cmd /c START /b http-server # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 From 9a3936240afdf83ad0082f7a193ef941527bbe24 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 23:11:50 +0200 Subject: [PATCH 24/30] added macos catalina tests --- ...s_ubuntu_tests.yml => uss_tests_linux.yml} | 2 +- ..._windows_tests.yml => uss_tests_macos.yml} | 17 ++-- .github/workflows/uss_tests_windows.yml | 91 +++++++++++++++++++ 3 files changed, 99 insertions(+), 11 deletions(-) rename .github/workflows/{uss_ubuntu_tests.yml => uss_tests_linux.yml} (99%) rename .github/workflows/{uss_windows_tests.yml => uss_tests_macos.yml} (89%) create mode 100644 .github/workflows/uss_tests_windows.yml diff --git a/.github/workflows/uss_ubuntu_tests.yml b/.github/workflows/uss_tests_linux.yml similarity index 99% rename from .github/workflows/uss_ubuntu_tests.yml rename to .github/workflows/uss_tests_linux.yml index 609d524..d602baa 100644 --- a/.github/workflows/uss_ubuntu_tests.yml +++ b/.github/workflows/uss_tests_linux.yml @@ -1,4 +1,4 @@ -name: uss-tests-ubuntu +name: uss-tests-linux # Controls when the workflow will run on: diff --git a/.github/workflows/uss_windows_tests.yml b/.github/workflows/uss_tests_macos.yml similarity index 89% rename from .github/workflows/uss_windows_tests.yml rename to .github/workflows/uss_tests_macos.yml index 347e648..055d071 100644 --- a/.github/workflows/uss_windows_tests.yml +++ b/.github/workflows/uss_tests_macos.yml @@ -1,4 +1,4 @@ -name: uss-tests-windows +name: uss-tests-macos # Controls when the workflow will run on: @@ -13,7 +13,7 @@ on: jobs: chrome-test: # The type of runner that the job will run on - runs-on: windows-latest + runs-on: macos-10.15 # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it @@ -22,12 +22,9 @@ jobs: # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install - # Installs the localhost server - - name: Install Server - run: npm install --global http-server - # Runs the locahost server - - name: Start server - run: cmd /c START /b http-server + # Install and start the localhost server in the background + - name: Run server + run: npx http-server -c-1 & # Runs a single command using the runners shell - name: Cypress run uses: cypress-io/github-action@v2 @@ -38,7 +35,7 @@ jobs: firefox-test: # The type of runner that the job will run on - runs-on: windows-latest + runs-on: macos-10.15 # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it @@ -60,7 +57,7 @@ jobs: edge-test: # The type of runner that the job will run on - runs-on: windows-latest + runs-on: macos-10.15 # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it diff --git a/.github/workflows/uss_tests_windows.yml b/.github/workflows/uss_tests_windows.yml new file mode 100644 index 0000000..1220127 --- /dev/null +++ b/.github/workflows/uss_tests_windows.yml @@ -0,0 +1,91 @@ +name: uss-tests-windows + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events for beta and master branches + push: + pull_request: + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + chrome-test: + # The type of runner that the job will run on + runs-on: windows-latest + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout + uses: actions/checkout@v3 + # Workaround for creating the package.json file + - name: Setup npm package + run: npm init -y && npm install + # Installs the localhost server + - name: Install Server + run: npm install --global http-server + # Runs the locahost server + - name: Run server + run: cmd /c START /b http-server + # Runs a single command using the runners shell + - name: Cypress run + uses: cypress-io/github-action@v2 + with: + wait-on: "http://localhost:8080" + build: npm i -D cypress + browser: chrome + + firefox-test: + # The type of runner that the job will run on + runs-on: windows-latest + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout + uses: actions/checkout@v3 + # Workaround for creating the package.json file + - name: Setup npm package + run: npm init -y && npm install + # Installs the localhost server + - name: Install Server + run: npm install --global http-server + # Runs the locahost server + - name: Run server + run: cmd /c START /b http-server + # Runs a single command using the runners shell + - name: Cypress run + uses: cypress-io/github-action@v2 + with: + wait-on: "http://localhost:8080" + build: npm i -D cypress + browser: firefox + + edge-test: + # The type of runner that the job will run on + runs-on: windows-latest + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout + uses: actions/checkout@v3 + # Workaround for creating the package.json file + - name: Setup npm package + run: npm init -y && npm install + # Installs edge + - uses: browser-actions/setup-edge@latest + - name: Print Edge version + run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion + # Installs the localhost server + - name: Install Server + run: npm install --global http-server + # Runs the locahost server + - name: Run server + run: cmd /c START /b http-server + # Runs a single command using the runners shell + - name: Cypress run + uses: cypress-io/github-action@v2 + with: + wait-on: "http://localhost:8080" + build: npm i -D cypress + browser: edge From 9775516b127cbd7be762a77cd59f6019c7c088fd Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 23:18:39 +0200 Subject: [PATCH 25/30] bugfix --- cypress/integration/x-axis-getters-tests.js | 2 +- cypress/integration/y-axis-getters-tests.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/integration/x-axis-getters-tests.js b/cypress/integration/x-axis-getters-tests.js index e73f22b..adda9c3 100644 --- a/cypress/integration/x-axis-getters-tests.js +++ b/cypress/integration/x-axis-getters-tests.js @@ -118,7 +118,7 @@ describe("getMaxScrollX-Body", function() { expect(Number.isFinite(uss.getMaxScrollX())).to.be.true; expect(uss.getMaxScrollX() > 0).to.be.true; - expect(uss.getMaxScrollX()).to.equal(uss.getPageScroller().scrollWidth / 2 + uss.getScrollbarsMaxDimension()); + expect(uss.getMaxScrollX()).to.equal(Math.floor(uss.getPageScroller().scrollWidth / 2 + uss.getScrollbarsMaxDimension())); //test elements that are unscrollable on the x-axis expect(uss.getMaxScrollX(win.document.getElementById("yScroller"))).to.equal(0); diff --git a/cypress/integration/y-axis-getters-tests.js b/cypress/integration/y-axis-getters-tests.js index 9956682..d41e036 100644 --- a/cypress/integration/y-axis-getters-tests.js +++ b/cypress/integration/y-axis-getters-tests.js @@ -118,7 +118,7 @@ describe("getMaxScrollY-Body", function() { expect(Number.isFinite(uss.getMaxScrollY())).to.be.true; expect(uss.getMaxScrollY() > 0).to.be.true; - expect(uss.getMaxScrollY()).to.equal(uss.getPageScroller().scrollHeight / 2 + uss.getScrollbarsMaxDimension()); + expect(uss.getMaxScrollY()).to.equal(Math.floor(uss.getPageScroller().scrollHeight / 2 + uss.getScrollbarsMaxDimension())); //test elements that are unscrollable on the y-axis expect(uss.getMaxScrollY(win.document.getElementById("xScroller"))).to.equal(0); From 2a5e36eea59ba90297af21b0d944f43a4393f19a Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 23:22:04 +0200 Subject: [PATCH 26/30] bugfix --- .github/workflows/uss_tests_linux.yml | 2 -- .github/workflows/uss_tests_macos.yml | 2 -- .github/workflows/uss_tests_windows.yml | 2 -- cypress/integration/x-axis-getters-tests.js | 2 +- cypress/integration/y-axis-getters-tests.js | 2 +- 5 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/uss_tests_linux.yml b/.github/workflows/uss_tests_linux.yml index d602baa..25957ef 100644 --- a/.github/workflows/uss_tests_linux.yml +++ b/.github/workflows/uss_tests_linux.yml @@ -69,8 +69,6 @@ jobs: # run: npm init -y && npm install # # Installs edge # - uses: browser-actions/setup-edge@latest -# - name: Print Edge version -# run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion # # Install and start the localhost server in the background # - name: Run server # run: npx http-server -c-1 & diff --git a/.github/workflows/uss_tests_macos.yml b/.github/workflows/uss_tests_macos.yml index 055d071..79e169d 100644 --- a/.github/workflows/uss_tests_macos.yml +++ b/.github/workflows/uss_tests_macos.yml @@ -68,8 +68,6 @@ jobs: run: npm init -y && npm install # Installs edge - uses: browser-actions/setup-edge@latest - - name: Print Edge version - run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion # Install and start the localhost server in the background - name: Run server run: npx http-server -c-1 & diff --git a/.github/workflows/uss_tests_windows.yml b/.github/workflows/uss_tests_windows.yml index 1220127..7831303 100644 --- a/.github/workflows/uss_tests_windows.yml +++ b/.github/workflows/uss_tests_windows.yml @@ -74,8 +74,6 @@ jobs: run: npm init -y && npm install # Installs edge - uses: browser-actions/setup-edge@latest - - name: Print Edge version - run: (Get-Item (Get-Command msedge).Source).VersionInfo.ProductVersion # Installs the localhost server - name: Install Server run: npm install --global http-server diff --git a/cypress/integration/x-axis-getters-tests.js b/cypress/integration/x-axis-getters-tests.js index adda9c3..6e84395 100644 --- a/cypress/integration/x-axis-getters-tests.js +++ b/cypress/integration/x-axis-getters-tests.js @@ -118,7 +118,7 @@ describe("getMaxScrollX-Body", function() { expect(Number.isFinite(uss.getMaxScrollX())).to.be.true; expect(uss.getMaxScrollX() > 0).to.be.true; - expect(uss.getMaxScrollX()).to.equal(Math.floor(uss.getPageScroller().scrollWidth / 2 + uss.getScrollbarsMaxDimension())); + expect(uss.getMaxScrollX()).to.equal(Math.round(uss.getPageScroller().scrollWidth / 2 + uss.getScrollbarsMaxDimension())); //test elements that are unscrollable on the x-axis expect(uss.getMaxScrollX(win.document.getElementById("yScroller"))).to.equal(0); diff --git a/cypress/integration/y-axis-getters-tests.js b/cypress/integration/y-axis-getters-tests.js index d41e036..5d11f51 100644 --- a/cypress/integration/y-axis-getters-tests.js +++ b/cypress/integration/y-axis-getters-tests.js @@ -118,7 +118,7 @@ describe("getMaxScrollY-Body", function() { expect(Number.isFinite(uss.getMaxScrollY())).to.be.true; expect(uss.getMaxScrollY() > 0).to.be.true; - expect(uss.getMaxScrollY()).to.equal(Math.floor(uss.getPageScroller().scrollHeight / 2 + uss.getScrollbarsMaxDimension())); + expect(uss.getMaxScrollY()).to.equal(Math.round(uss.getPageScroller().scrollHeight / 2 + uss.getScrollbarsMaxDimension())); //test elements that are unscrollable on the y-axis expect(uss.getMaxScrollY(win.document.getElementById("xScroller"))).to.equal(0); From 15f9ac62f7306c68a838402bb79618e401e32848 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Wed, 18 May 2022 23:29:48 +0200 Subject: [PATCH 27/30] bugfix --- .github/workflows/uss_tests_linux.yml | 5 +++-- .github/workflows/uss_tests_macos.yml | 5 +++-- .github/workflows/uss_tests_windows.yml | 5 +++-- cypress/integration/x-axis-getters-tests.js | 5 +++-- cypress/integration/y-axis-getters-tests.js | 3 ++- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/uss_tests_linux.yml b/.github/workflows/uss_tests_linux.yml index 25957ef..7ed366d 100644 --- a/.github/workflows/uss_tests_linux.yml +++ b/.github/workflows/uss_tests_linux.yml @@ -67,8 +67,9 @@ jobs: # # Workaround for creating the package.json file # - name: Setup npm package # run: npm init -y && npm install -# # Installs edge -# - uses: browser-actions/setup-edge@latest +# # Installs Edge +# - name: Install Microsoft Edge +# uses: browser-actions/setup-edge@latest # # Install and start the localhost server in the background # - name: Run server # run: npx http-server -c-1 & diff --git a/.github/workflows/uss_tests_macos.yml b/.github/workflows/uss_tests_macos.yml index 79e169d..5c54062 100644 --- a/.github/workflows/uss_tests_macos.yml +++ b/.github/workflows/uss_tests_macos.yml @@ -66,8 +66,9 @@ jobs: # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install - # Installs edge - - uses: browser-actions/setup-edge@latest + # Installs Edge + - name: Install Microsoft Edge + uses: browser-actions/setup-edge@latest # Install and start the localhost server in the background - name: Run server run: npx http-server -c-1 & diff --git a/.github/workflows/uss_tests_windows.yml b/.github/workflows/uss_tests_windows.yml index 7831303..a28641d 100644 --- a/.github/workflows/uss_tests_windows.yml +++ b/.github/workflows/uss_tests_windows.yml @@ -72,8 +72,9 @@ jobs: # Workaround for creating the package.json file - name: Setup npm package run: npm init -y && npm install - # Installs edge - - uses: browser-actions/setup-edge@latest + # Installs Edge + - name: Install Microsoft Edge + uses: browser-actions/setup-edge@latest # Installs the localhost server - name: Install Server run: npm install --global http-server diff --git a/cypress/integration/x-axis-getters-tests.js b/cypress/integration/x-axis-getters-tests.js index 6e84395..264df38 100644 --- a/cypress/integration/x-axis-getters-tests.js +++ b/cypress/integration/x-axis-getters-tests.js @@ -115,10 +115,11 @@ describe("getMaxScrollX-Body", function() { .then((win) => { uss = win.uss; uss._containersData = new Map(); - + const _expectedMaxScrollX = uss.getPageScroller().scrollWidth / 2 + uss.getScrollbarsMaxDimension(); + expect(Number.isFinite(uss.getMaxScrollX())).to.be.true; expect(uss.getMaxScrollX() > 0).to.be.true; - expect(uss.getMaxScrollX()).to.equal(Math.round(uss.getPageScroller().scrollWidth / 2 + uss.getScrollbarsMaxDimension())); + expect(uss.getMaxScrollX()).to.be.closeTo(_expectedMaxScrollX, 1); //test elements that are unscrollable on the x-axis expect(uss.getMaxScrollX(win.document.getElementById("yScroller"))).to.equal(0); diff --git a/cypress/integration/y-axis-getters-tests.js b/cypress/integration/y-axis-getters-tests.js index 5d11f51..b22cd8a 100644 --- a/cypress/integration/y-axis-getters-tests.js +++ b/cypress/integration/y-axis-getters-tests.js @@ -115,10 +115,11 @@ describe("getMaxScrollY-Body", function() { .then((win) => { uss = win.uss; uss._containersData = new Map(); + const _expectedMaxScrollY = uss.getPageScroller().scrollHeight / 2 + uss.getScrollbarsMaxDimension(); expect(Number.isFinite(uss.getMaxScrollY())).to.be.true; expect(uss.getMaxScrollY() > 0).to.be.true; - expect(uss.getMaxScrollY()).to.equal(Math.round(uss.getPageScroller().scrollHeight / 2 + uss.getScrollbarsMaxDimension())); + expect(uss.getMaxScrollY()).to.be.closeTo(_expectedMaxScrollY, 1); //test elements that are unscrollable on the y-axis expect(uss.getMaxScrollY(win.document.getElementById("xScroller"))).to.equal(0); From fed1e743daf4a60377f7b92a64c857e8897d5f9b Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Thu, 19 May 2022 15:00:43 +0200 Subject: [PATCH 28/30] bugfixes --- docs/ConstantsAbout.md | 1 - js/universalsmoothscroll.js | 104 +++++++++++++++++++++--------------- 2 files changed, 61 insertions(+), 44 deletions(-) diff --git a/docs/ConstantsAbout.md b/docs/ConstantsAbout.md index ceb148e..6a0a6b1 100644 --- a/docs/ConstantsAbout.md +++ b/docs/ConstantsAbout.md @@ -20,7 +20,6 @@ Name | Type | Description `DEFAULT_MIN_ANIMATION_FRAMES` | `Number` | The initial value of the `uss._minAnimationFrame` variable: it represent the default lowest number of frames any scroll-animation should last if no [`StepLengthCalculator`](./FAQ.md#q-what-is-a-steplengthcalculator-) is set for a container.
It's **51 frames at 929px** of _(initial window's)_ height. `DEFAULT_TEST_CALCULATOR_SCROLL_VALUE` | `Number` | The default number of pixel scrolled when testing a newStepLengthCalculator. `DEFAULT_TEST_CALCULATOR_DURATION` | `Number` | The default number of milliseconds the test of a newStepLengthCalculator should last. -`DEFAULT_PAGE_SCROLLER` | `Object` | The initial value of the `uss_pageScroller` variable: it represent the default value used when an API method requires the `container` input parameter but nothing is passed. `DEFAULT_ERROR_LOGGER` | `Function` | A function that logs the API error messages inside the browser's console. `DEFAULT_WARNING_LOGGER` | `Function` | A function that logs the API warning messages inside the browser's console. diff --git a/js/universalsmoothscroll.js b/js/universalsmoothscroll.js index b2a6059..43ec04f 100644 --- a/js/universalsmoothscroll.js +++ b/js/universalsmoothscroll.js @@ -11,8 +11,6 @@ * it represent the default lowest number of frames any scroll-animation should last if no StepLengthCalculator is set for a container. * DEFAULT_TEST_CALCULATOR_SCROLL_VALUE: number, the default number of pixel scrolled when testing a newScrollCalculator. * DEFAULT_TEST_CALCULATOR_DURATION: number, the default number of milliseconds the test of a newStepLengthCalculator should last. - * DEFAULT_PAGE_SCROLLER: object, the initial value of the uss_pageScroller variable: - * it represent the default value used when an API method requires the "container" input parameter but nothing is passed. * DEFAULT_ERROR_LOGGER: function, logs the API error messages inside the browser's console. * DEFAULT_WARNING_LOGGER: function, logs the API warning messages inside the browser's console. */ @@ -149,7 +147,6 @@ const DEFAULT_YSTEP_LENGTH = Math.max(1, Math.abs(38 - 20 / 140 * (INITIAL_WINDO const DEFAULT_MIN_ANIMATION_FRAMES = INITIAL_WINDOW_HEIGHT / DEFAULT_YSTEP_LENGTH; //51 frames at 929px of height const DEFAULT_TEST_CALCULATOR_SCROLL_VALUE = 100; //in px const DEFAULT_TEST_CALCULATOR_DURATION = 5000; //in ms -const DEFAULT_PAGE_SCROLLER = window; const DEFAULT_ERROR_LOGGER = (functionName, expectedValue, receivedValue) => { if(/disabled/i.test(uss._debugMode)) return; @@ -221,7 +218,7 @@ var uss = { _windowHeight: INITIAL_WINDOW_HEIGHT, _windowWidth: INITIAL_WINDOW_WIDTH, _scrollbarsMaxDimension: 0, - _pageScroller: DEFAULT_PAGE_SCROLLER, + _pageScroller: document.scrollingElement || window, _reducedMotion: "matchMedia" in window && window.matchMedia("(prefers-reduced-motion)").matches, _debugMode: "", isXscrolling: (container = uss._pageScroller) => { @@ -511,13 +508,15 @@ var uss = { return deltaY >= uss._minAnimationFrame * uss._yStepLength ? uss._yStepLength : Math.ceil(deltaY / uss._minAnimationFrame); }, calcScrollbarsDimensions: (element) => { - if(element === window) return [0, 0]; //[Vertical scrollbar's width, Horizontal scrollbar's height] - if(!(element instanceof HTMLElement)) { + if(element === window) { + element = document.scrollingElement || uss.getPageScroller(); + if(element === window) return [0,0]; + } else if(!(element instanceof HTMLElement)) { DEFAULT_ERROR_LOGGER("calcScrollbarsDimensions", "the element to be an HTMLElement or the Window", element); throw "USS fatal error (execution stopped)"; } - if(uss._scrollbarsMaxDimension === 0) return [0, 0]; //[Vertical scrollbar's width, Horizontal scrollbar's height] + if(uss._scrollbarsMaxDimension === 0) return [0,0]; //[Vertical scrollbar's width, Horizontal scrollbar's height] const _scrollbarsDimensions = []; const _elementStyle = window.getComputedStyle(element); @@ -556,7 +555,10 @@ var uss = { return _scrollbarsDimensions; }, calcBordersDimensions: (element) => { - if(element === window) return [0,0,0,0]; //[top, right, bottom, left] + if(element === window) { + element = document.scrollingElement || uss.getPageScroller(); + if(element === window) return [0,0,0,0]; //[top, right, bottom, left] + } if(!(element instanceof HTMLElement)) { DEFAULT_ERROR_LOGGER("calcBordersDimensions", "the element to be an HTMLElement or the Window", element); throw "USS fatal error (execution stopped)"; @@ -648,7 +650,7 @@ var uss = { const _overflowRegex = includeHiddenParents ? /(auto|scroll|hidden)/ : /(auto|scroll)/; const _relativePositioned = _style.position !== "absolute"; - while(element !== _body && element !== _html) { + do { element = element.parentElement; _style = window.getComputedStyle(element); if(element === _body) break; @@ -659,7 +661,7 @@ var uss = { return element; } if(_style.position === "fixed") return null; //If this parent is fixed, no other parent can scroll the element - } + } while(true); //Until body is reached if(_bodyOverflowRegex.test(_style.overflowX) && uss.getMaxScrollX(_body) >= 1) return _body; if(_bodyOverflowRegex.test(window.getComputedStyle(_html).overflowX) && uss.getMaxScrollX(_html) >= 1) return _html; @@ -693,7 +695,7 @@ var uss = { const _overflowRegex = includeHiddenParents ? /(auto|scroll|hidden)/ : /(auto|scroll)/; const _relativePositioned = _style.position !== "absolute"; - while(element !== _body && element !== _html) { + do { element = element.parentElement; _style = window.getComputedStyle(element); if(element === _body) break; @@ -704,7 +706,7 @@ var uss = { return element; } if(_style.position === "fixed") return null; //If this parent is fixed, no other parent can scroll the element - } + } while(true); //Until body is reached if(_bodyOverflowRegex.test(_style.overflowY) && uss.getMaxScrollY(_body) >= 1) return _body; if(_bodyOverflowRegex.test(window.getComputedStyle(_html).overflowY) && uss.getMaxScrollY(_html) >= 1) return _html; @@ -739,7 +741,7 @@ var uss = { const _overflowRegex = includeHiddenParents ? /(auto|scroll|hidden)/ : /(auto|scroll)/; const _relativePositioned = _style.position !== "absolute"; - while(element !== _body && element !== _html) { + do { element = element.parentElement; _style = window.getComputedStyle(element); if(element === _body) break; @@ -750,7 +752,7 @@ var uss = { return element; } if(_style.position === "fixed") return null; //If this parent is fixed, no other parent can scroll the element - } + } while(true); //Until body is reached if(_bodyOverflowRegex.test(_style.overflow) && _isScrollable(_body)) return _body; if(_bodyOverflowRegex.test(window.getComputedStyle(_html).overflow) && _isScrollable(_html)) return _html; @@ -791,7 +793,7 @@ var uss = { const _overflowRegex = includeHiddenParents ? /(auto|scroll|hidden)/ : /(auto|scroll)/; const _relativePositioned = _style.position !== "absolute"; - while(element !== _body && element !== _html) { + do { element = element.parentElement; _style = window.getComputedStyle(element); if(element === _body) break; @@ -802,7 +804,7 @@ var uss = { _scrollableParentFound(element); } if(_style.position === "fixed") return _scrollableParents; //If this parent is fixed, no other parent can scroll the element - } + } while(true); //Until body is reached if(_bodyOverflowRegex.test(_style.overflow) && _isScrollable(_body)) _scrollableParentFound(_body); if(_bodyOverflowRegex.test(window.getComputedStyle(_html).overflow) && _isScrollable(_html)) _scrollableParentFound(_html); @@ -1154,36 +1156,44 @@ var uss = { if(typeof callback === "function") window.requestAnimationFrame(callback); return; } - + let _alignToTop = alignToTop; let _alignToLeft = alignToLeft; - let _currentElement, _currentContainer; - - _currentContainer = _containers[_containerIndex]; - _currentElement = _containerIndex < 1 ? element : _containers[_containerIndex - 1]; + let _currentContainer = _containers[_containerIndex]; + let _currentElement = _containers[_containerIndex - 1]; + + //The window can scroll the body and/or the html, + //there's no need to scroll them after having scrolled the window. + if(_currentContainer === window && + (_currentElement === document.body || _currentElement === document.documentElement) + ) { + _containerIndex--; + _containers[_containerIndex] = window; + } + _currentElement = _containerIndex < 1 ? element : _containers[_containerIndex - 1]; _scrollContainer(); function _scrollContainer() { - //_scrollbarsDimensions[0] = current __container's vertical scrollbar's width - //_scrollbarsDimensions[1] = current __container's horizontal scrollbar's height + //_scrollbarsDimensions[0] = _currentContainer's vertical scrollbar's width + //_scrollbarsDimensions[1] = _currentContainer's horizontal scrollbar's height const _scrollbarsDimensions = uss.calcScrollbarsDimensions(_currentContainer); - //_bordersDimensions[0] = current __container's top border size - //_bordersDimensions[1] = current __container's right border size - //_bordersDimensions[2] = current __container's bottom border size - //_bordersDimensions[3] = current __container's left border size + //_bordersDimensions[0] = _currentContainer's top border size + //_bordersDimensions[1] = _currentContainer's right border size + //_bordersDimensions[2] = _currentContainer's bottom border size + //_bordersDimensions[3] = _currentContainer's left border size const _bordersDimensions = uss.calcBordersDimensions(_currentContainer); const _containerRect = _currentContainer !== window ? _currentContainer.getBoundingClientRect() : {left: 0, top: 0, width: uss._windowWidth, height: uss._windowHeight}; const _containerWidth = _containerRect.width; const _containerHeight = _containerRect.height; - const _elementRect = _currentElement.getBoundingClientRect(); //The element can never be the window + const _elementRect = _currentElement.getBoundingClientRect(); //_currentElement can never be the window const _elementWidth = _elementRect.width; const _elementHeight = _elementRect.height; - const _elementInitialX = _elementRect.left - _containerRect.left; //Element's x-coordinate relative to it's container - const _elementInitialY = _elementRect.top - _containerRect.top; //Element's y-coordinate relative to it's container + const _elementInitialX = _elementRect.left - _containerRect.left; //_currentElement's x-coordinate relative to it's container + const _elementInitialY = _elementRect.top - _containerRect.top; //_currentElement's y-coordinate relative to it's container //Align to "nearest" is an indirect way to say: Align to "top" / "bottom" / "center" if(alignToLeft === "nearest") { @@ -1243,33 +1253,41 @@ var uss = { let _alignToTop = null; let _alignToLeft = null; - let _currentElement, _currentContainer; - - _currentContainer = _containers[_containerIndex]; - _currentElement = _containerIndex < 1 ? element : _containers[_containerIndex - 1]; + let _currentContainer = _containers[_containerIndex]; + let _currentElement = _containers[_containerIndex - 1]; + + //The window can scroll the body and/or the html, + //there's no need to scroll them after having scrolled the window. + if(_currentContainer === window && + (_currentElement === document.body || _currentElement === document.documentElement) + ) { + _containerIndex--; + _containers[_containerIndex] = window; + } + _currentElement = _containerIndex < 1 ? element : _containers[_containerIndex - 1]; _scrollContainer(); function _scrollContainer() { - //_scrollbarsDimensions[0] = current __container's vertical scrollbar's width - //_scrollbarsDimensions[1] = current __container's horizontal scrollbar's height + //_scrollbarsDimensions[0] = _currentContainer's vertical scrollbar's width + //_scrollbarsDimensions[1] = _currentContainer's horizontal scrollbar's height const _scrollbarsDimensions = uss.calcScrollbarsDimensions(_currentContainer); - //_bordersDimensions[0] = current __container's top border size - //_bordersDimensions[1] = current __container's right border size - //_bordersDimensions[2] = current __container's bottom border size - //_bordersDimensions[3] = current __container's left border size + //_bordersDimensions[0] = _currentContainer's top border size + //_bordersDimensions[1] = _currentContainer's right border size + //_bordersDimensions[2] = _currentContainer's bottom border size + //_bordersDimensions[3] = _currentContainer's left border size const _bordersDimensions = uss.calcBordersDimensions(_currentContainer); const _containerRect = _currentContainer !== window ? _currentContainer.getBoundingClientRect() : {left: 0, top: 0, width: uss._windowWidth, height: uss._windowHeight}; const _containerWidth = _containerRect.width; const _containerHeight = _containerRect.height; - const _elementRect = _currentElement.getBoundingClientRect(); //The element can never be the window + const _elementRect = _currentElement.getBoundingClientRect(); //_currentElement can never be the window const _elementWidth = _elementRect.width; const _elementHeight = _elementRect.height; - const _elementInitialX = _elementRect.left - _containerRect.left; //Element's x-coordinate relative to it's container - const _elementInitialY = _elementRect.top - _containerRect.top; //Element's y-coordinate relative to it's container + const _elementInitialX = _elementRect.left - _containerRect.left; //_currentElement's x-coordinate relative to it's container + const _elementInitialY = _elementRect.top - _containerRect.top; //_currentElement's y-coordinate relative to it's container const _elementIntoViewX = _elementInitialX > -1 && _elementInitialX + _elementWidth - _containerWidth + _scrollbarsDimensions[0] < 1; //Checks if the element is already in the viewport on the x-axis const _elementIntoViewY = _elementInitialY > -1 && _elementInitialY + _elementHeight - _containerHeight + _scrollbarsDimensions[1] < 1; //Checks if the element is already in the viewport on the y-axis From c7d0f7fd632b23c8b7573e1c78b05ff512ea4c58 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Thu, 19 May 2022 15:08:14 +0200 Subject: [PATCH 29/30] Update universalsmoothscroll-min.js --- js/universalsmoothscroll-min.js | 99 +++++++++++++++++---------------- 1 file changed, 51 insertions(+), 48 deletions(-) diff --git a/js/universalsmoothscroll-min.js b/js/universalsmoothscroll-min.js index d7925c5..5acc4c1 100644 --- a/js/universalsmoothscroll-min.js +++ b/js/universalsmoothscroll-min.js @@ -1,60 +1,63 @@ var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b=a?DEFAULT_ERROR_LOGGER("setXStepLength","the newXStepLength to be a positive number",a):uss._xStepLength=a},setYStepLength:function(a){!Number.isFinite(a)||0>=a?DEFAULT_ERROR_LOGGER("setYStepLength","the newYStepLength to be a positive number",a):uss._yStepLength=a},setStepLength:function(a){!Number.isFinite(a)|| +setXStepLengthCalculator:function(a,b,c,d){b=void 0===b?uss._pageScroller:b;c=void 0===c?!1:c;d=void 0===d?!1:d;if("function"!==typeof a)DEFAULT_ERROR_LOGGER("setXStepLengthCalculator","the newCalculator to be a function",a);else if(b===window||b instanceof HTMLElement){if(d){d=performance.now();var f=DEFAULT_TEST_CALCULATOR_SCROLL_VALUE;do{var e=performance.now();var h=a(f,d,e,DEFAULT_TEST_CALCULATOR_SCROLL_VALUE,DEFAULT_TEST_CALCULATOR_SCROLL_VALUE-f,DEFAULT_TEST_CALCULATOR_SCROLL_VALUE,b);if(!Number.isFinite(h)){DEFAULT_ERROR_LOGGER("setXStepLengthCalculator", +"the newCalculator to return a valid step value",h);return}f-=h}while(0DEFAULT_TEST_CALCULATOR_DURATION&&DEFAULT_WARNING_LOGGER(a.name||"the passed calculator","didn't complete the test scroll-animation within "+DEFAULT_TEST_CALCULATOR_DURATION+"ms",!1)}f=(d=uss._containersData.get(b))||[];c?f[14]=a:(f[12]=a,f[14]&&(f[14]=null));d||uss._containersData.set(b,f)}else DEFAULT_ERROR_LOGGER("setXStepLengthCalculator","the container to be an HTMLElement or the Window", +b)},setYStepLengthCalculator:function(a,b,c,d){b=void 0===b?uss._pageScroller:b;c=void 0===c?!1:c;d=void 0===d?!1:d;if("function"!==typeof a)DEFAULT_ERROR_LOGGER("setYStepLengthCalculator","the newCalculator to be a function",a);else if(b===window||b instanceof HTMLElement){if(d){d=performance.now();var f=DEFAULT_TEST_CALCULATOR_SCROLL_VALUE;do{var e=performance.now();var h=a(f,d,e,DEFAULT_TEST_CALCULATOR_SCROLL_VALUE,DEFAULT_TEST_CALCULATOR_SCROLL_VALUE-f,DEFAULT_TEST_CALCULATOR_SCROLL_VALUE,b); +if(!Number.isFinite(h)){DEFAULT_ERROR_LOGGER("setYStepLengthCalculator","the newCalculator to return a valid step value",h);return}f-=h}while(0DEFAULT_TEST_CALCULATOR_DURATION&&DEFAULT_WARNING_LOGGER(a.name||"the passed calculator","didn't complete the test scroll-animation within "+DEFAULT_TEST_CALCULATOR_DURATION+"ms",!1)}f=(d=uss._containersData.get(b))||[];c?f[15]=a:(f[13]=a,f[15]&&(f[15]=null));d||uss._containersData.set(b,f)}else DEFAULT_ERROR_LOGGER("setYStepLengthCalculator", +"the container to be an HTMLElement or the Window",b)},setStepLengthCalculator:function(a,b,c,d){b=void 0===b?uss._pageScroller:b;c=void 0===c?!1:c;d=void 0===d?!1:d;if("function"!==typeof a)DEFAULT_ERROR_LOGGER("setStepLengthCalculator","the newCalculator to be a function",a);else if(b===window||b instanceof HTMLElement){if(d){d=performance.now();var f=DEFAULT_TEST_CALCULATOR_SCROLL_VALUE;do{var e=performance.now();var h=a(f,d,e,DEFAULT_TEST_CALCULATOR_SCROLL_VALUE,DEFAULT_TEST_CALCULATOR_SCROLL_VALUE- +f,DEFAULT_TEST_CALCULATOR_SCROLL_VALUE,b);if(!Number.isFinite(h)){DEFAULT_ERROR_LOGGER("setStepLengthCalculator","the newCalculator to return a valid step value",h);return}f-=h}while(0DEFAULT_TEST_CALCULATOR_DURATION&&DEFAULT_WARNING_LOGGER(a.name||"the passed calculator","didn't complete the test scroll-animation within "+DEFAULT_TEST_CALCULATOR_DURATION+"ms",!1)}f=(d=uss._containersData.get(b))||[];c?(f[14]=a,f[15]=a):(f[12]=a,f[13]=a,f[14]&&(f[14]= +null),f[15]&&(f[15]=null));d||uss._containersData.set(b,f)}else DEFAULT_ERROR_LOGGER("setStepLengthCalculator","the container to be an HTMLElement or the Window",b)},setXStepLength:function(a){!Number.isFinite(a)||0>=a?DEFAULT_ERROR_LOGGER("setXStepLength","the newXStepLength to be a positive number",a):uss._xStepLength=a},setYStepLength:function(a){!Number.isFinite(a)||0>=a?DEFAULT_ERROR_LOGGER("setYStepLength","the newYStepLength to be a positive number",a):uss._yStepLength=a},setStepLength:function(a){!Number.isFinite(a)|| 0>=a?DEFAULT_ERROR_LOGGER("setStepLength","the newStepLength to be a positive number",a):(uss._xStepLength=a,uss._yStepLength=a)},setMinAnimationFrame:function(a){!Number.isFinite(a)||0>=a?DEFAULT_ERROR_LOGGER("setMinAnimationFrame","the newMinAnimationFrame to be a positive number",a):uss._minAnimationFrame=a},setPageScroller:function(a){a===window||a instanceof HTMLElement?uss._pageScroller=a:DEFAULT_ERROR_LOGGER("setPageScroller","the newPageScroller to be an HTMLElement or the Window",a)},setDebugMode:function(a){a= void 0===a?"":a;if("string"!==typeof a){var b=null;/disabled/i.test(uss._debugMode)&&(b=uss._debugMode,uss._debugMode="legacy");DEFAULT_ERROR_LOGGER("setDebugMode",'the newDebugMode to be "disabled", "legacy" or any other string',a);b&&(uss._debugMode=b)}else uss._debugMode=a},calcXStepLength:function(a){if(!Number.isFinite(a)||0>a)throw DEFAULT_ERROR_LOGGER("calcXStepLength","the deltaX to be a positive number",a),"USS fatal error (execution stopped)";return a>=uss._minAnimationFrame*uss._xStepLength? -uss._xStepLength:Math.ceil(a/uss._minAnimationFrame)},calcYStepLength:function(a){if(!Number.isFinite(a)||0>a)throw DEFAULT_ERROR_LOGGER("calcYStepLength","the deltaY to be a positive number",a),"USS fatal error (execution stopped)";return a>=uss._minAnimationFrame*uss._yStepLength?uss._yStepLength:Math.ceil(a/uss._minAnimationFrame)},calcScrollbarsDimensions:function(a){if(a===window)return[0,0];if(!(a instanceof HTMLElement))throw DEFAULT_ERROR_LOGGER("calcScrollbarsDimensions","the element to be an HTMLElement or the Window", -a),"USS fatal error (execution stopped)";if(0===uss._scrollbarsMaxDimension)return[0,0];var b=[],c=window.getComputedStyle(a),d=Number.parseInt(c.width),f=Number.parseInt(c.height),e=a.clientWidth,k=a.clientHeight,q=a.style.overflowX,t=a.style.overflowY,g=a.scrollLeft,h=a.scrollTop;a.style.overflowX="hidden";a.style.overflowY="hidden";b[0]=Number.parseInt(c.width)-d;b[1]=Number.parseInt(c.height)-f;0===b[0]?b[0]=a.clientWidth-e:0>b[0]&&(b[0]=0);0===b[1]?b[1]=a.clientHeight-k:0>b[1]&&(b[1]=0);a.style.overflowX= -q;a.style.overflowY=t;a.scrollLeft=g;a.scrollTop=h;return b},calcBordersDimensions:function(a){if(a===window)return[0,0,0,0];if(!(a instanceof HTMLElement))throw DEFAULT_ERROR_LOGGER("calcBordersDimensions","the element to be an HTMLElement or the Window",a),"USS fatal error (execution stopped)";a=window.getComputedStyle(a);return[Number.parseInt(a.borderTopWidth),Number.parseInt(a.borderRightWidth),Number.parseInt(a.borderBottomWidth),Number.parseInt(a.borderLeftWidth)]},getScrollXCalculator:function(a){a= -void 0===a?uss._pageScroller:a;return a===window?function(){return window.scrollX}:a instanceof HTMLElement?function(){return a.scrollLeft}:function(){DEFAULT_ERROR_LOGGER("getScrollXCalculator","the container to be an HTMLElement or the Window",a);throw"USS fatal error (execution stopped)";}},getScrollYCalculator:function(a){a=void 0===a?uss._pageScroller:a;return a===window?function(){return window.scrollY}:a instanceof HTMLElement?function(){return a.scrollTop}:function(){DEFAULT_ERROR_LOGGER("getScrollYCalculator", -"the container to be an HTMLElement or the Window",a);throw"USS fatal error (execution stopped)";}},getMaxScrollX:function(a){a=void 0===a?uss._pageScroller:a;if(a===window){var b=window.scrollX;a.scroll(1073741824,window.scrollY);var c=window.scrollX;a.scroll(b,window.scrollY);return c}if(a===document.documentElement||a===document.body)return b=a.scrollLeft,a.scrollLeft=1073741824,c=a.scrollLeft,a.scrollLeft=b,c;if(a instanceof HTMLElement)return a.scrollWidth-a.clientWidth;DEFAULT_ERROR_LOGGER("getMaxScrollX", -"the container to be an HTMLElement or the Window",a)},getMaxScrollY:function(a){a=void 0===a?uss._pageScroller:a;if(a===window){var b=window.scrollY;a.scroll(window.scrollX,1073741824);var c=window.scrollY;a.scroll(window.scrollX,b);return c}if(a===document.documentElement||a===document.body)return b=a.scrollTop,a.scrollTop=1073741824,c=a.scrollTop,a.scrollTop=b,c;if(a instanceof HTMLElement)return a.scrollHeight-a.clientHeight;DEFAULT_ERROR_LOGGER("getMaxScrollY","the container to be an HTMLElement or the Window", -a)},getXScrollableParent:function(a,b){b=void 0===b?!1:b;if(a===window)return null;if(!(a instanceof HTMLElement))return DEFAULT_ERROR_LOGGER("getXScrollableParent","the element to be an HTMLElement or the Window",a),null;var c=b?/(auto|scroll|hidden|visible)/:/(auto|scroll|visible)/,d=document.documentElement,f=document.body;if(a===f){if(c.test(window.getComputedStyle(d).overflowX)&&1<=uss.getMaxScrollX(d))return d;a=d}if(a===d)return 1<=uss.getMaxScrollX(window)?window:null;var e=window.getComputedStyle(a); -if("fixed"===e.position)return null;for(var k=b?/(auto|scroll|hidden)/:/(auto|scroll)/,q="absolute"!==e.position;a!==f&&a!==d;){a=a.parentElement;e=window.getComputedStyle(a);if(a===f)break;if((q||"static"!==e.position)&&a.scrollWidth>a.clientWidth&&k.test(e.overflowX))return a;if("fixed"===e.position)return null}return c.test(e.overflowX)&&1<=uss.getMaxScrollX(f)?f:c.test(window.getComputedStyle(d).overflowX)&&1<=uss.getMaxScrollX(d)?d:1<=uss.getMaxScrollX(window)?window:null},getYScrollableParent:function(a, -b){b=void 0===b?!1:b;if(a===window)return null;if(!(a instanceof HTMLElement))return DEFAULT_ERROR_LOGGER("getYScrollableParent","the element to be an HTMLElement or the Window",a),null;var c=b?/(auto|scroll|hidden|visible)/:/(auto|scroll|visible)/,d=document.documentElement,f=document.body;if(a===f){if(c.test(window.getComputedStyle(d).overflowY)&&1<=uss.getMaxScrollY(d))return d;a=d}if(a===d)return 1<=uss.getMaxScrollY(window)?window:null;var e=window.getComputedStyle(a);if("fixed"===e.position)return null; -for(var k=b?/(auto|scroll|hidden)/:/(auto|scroll)/,q="absolute"!==e.position;a!==f&&a!==d;){a=a.parentElement;e=window.getComputedStyle(a);if(a===f)break;if((q||"static"!==e.position)&&a.scrollHeight>a.clientHeight&&k.test(e.overflowY))return a;if("fixed"===e.position)return null}return c.test(e.overflowY)&&1<=uss.getMaxScrollY(f)?f:c.test(window.getComputedStyle(d).overflowY)&&1<=uss.getMaxScrollY(d)?d:1<=uss.getMaxScrollY(window)?window:null},getScrollableParent:function(a,b){b=void 0===b?!1:b; -if(a===window)return null;if(!(a instanceof HTMLElement))return DEFAULT_ERROR_LOGGER("getScrollableParent","the element to be an HTMLElement or the Window",a),null;var c=b?/(auto|scroll|hidden|visible)/:/(auto|scroll|visible)/,d=document.documentElement,f=document.body,e=function(g){return 1<=uss.getMaxScrollX(g)||1<=uss.getMaxScrollY(g)};if(a===f){if(c.test(window.getComputedStyle(d).overflow)&&e(d))return d;a=d}if(a===d)return e(window)?window:null;var k=window.getComputedStyle(a);if("fixed"=== -k.position)return null;for(var q=b?/(auto|scroll|hidden)/:/(auto|scroll)/,t="absolute"!==k.position;a!==f&&a!==d;){a=a.parentElement;k=window.getComputedStyle(a);if(a===f)break;if((t||"static"!==k.position)&&(a.scrollWidth>a.clientWidth||a.scrollHeight>a.clientHeight)&&q.test(k.overflow))return a;if("fixed"===k.position)return null}return c.test(k.overflow)&&e(f)?f:c.test(window.getComputedStyle(d).overflow)&&e(d)?d:e(window)?window:null},getAllScrollableParents:function(a,b,c){b=void 0===b?!1:b; -if(a===window)return[];if(!(a instanceof HTMLElement))return DEFAULT_ERROR_LOGGER("getAllScrollableParents","the element to be an HTMLElement or the Window",a),[];var d=b?/(auto|scroll|hidden|visible)/:/(auto|scroll|visible)/,f=document.documentElement,e=document.body,k=[],q="function"===typeof c?c:function(){};c=function(m){return 1<=uss.getMaxScrollX(m)||1<=uss.getMaxScrollY(m)};var t=function(m){k.push(m);q(m)};a===e&&(d.test(window.getComputedStyle(f).overflow)&&c(f)&&t(f),a=f);if(a===f)return c(window)&& -t(window),k;var g=window.getComputedStyle(a);if("fixed"===g.position)return k;b=b?/(auto|scroll|hidden)/:/(auto|scroll)/;for(var h="absolute"!==g.position;a!==e&&a!==f;){a=a.parentElement;g=window.getComputedStyle(a);if(a===e)break;(h||"static"!==g.position)&&(a.scrollWidth>a.clientWidth||a.scrollHeight>a.clientHeight)&&b.test(g.overflow)&&t(a);if("fixed"===g.position)return k}d.test(g.overflow)&&c(e)&&t(e);d.test(window.getComputedStyle(f).overflow)&&c(f)&&t(f);c(window)&&t(window);return k},scrollXTo:function(a, -b,c){function d(h){var m=g[2],r=g[4],l=f(),n=(m-l)*r;if(1>n)uss.stopScrollingX(b,g[10]);else{try{var u=g[0];var p=g[14]?g[14](n,g[8],h,g[6],l,m,b):g[12](n,g[8],h,g[6],l,m,b);if(u!==g[0])return;if(m!==g[2]){g[0]=window.requestAnimationFrame(d);return}Number.isFinite(p)||(DEFAULT_WARNING_LOGGER(p,"is not a valid step length",!0),p=uss.calcXStepLength(e))}catch(v){p=uss.calcXStepLength(e)}n<=p?(q(m),uss.stopScrollingX(b,g[10])):(q(l+p*r),0!==p&&l===f()?uss.stopScrollingX(b,g[10]):g[0]=window.requestAnimationFrame(d))}} -b=void 0===b?uss._pageScroller:b;if(Number.isFinite(a))if(b===window||b instanceof HTMLElement)if(1>uss.getMaxScrollX(b))a=b===window?"window":b.tagName.toLowerCase()+(b.id?"#"+b.id:"")+(b.className?"."+b.className:""),DEFAULT_WARNING_LOGGER(a,"is not scrollable on the x-axis",!1),uss.stopScrollingX(b,c);else{var f=uss.getScrollXCalculator(b),e=a-f(),k=0e)uss.stopScrollingX(b,c);else{var q=b!==window?function(h){return b.scrollLeft=h}:function(h){return b.scroll(h,window.scrollY)}; -if(uss._reducedMotion)q(a),uss.stopScrollingX(b,c);else{var t=uss._containersData.get(b),g=t||[];g[2]=a;g[4]=k;g[6]=e;g[8]=performance.now();g[10]=c;g[0]||(g[0]=window.requestAnimationFrame(d),t||uss._containersData.set(b,g))}}}else DEFAULT_ERROR_LOGGER("scrollXTo","the container to be an HTMLElement or the Window",b);else DEFAULT_ERROR_LOGGER("scrollXTo","the finalXPosition to be a number",a)},scrollYTo:function(a,b,c){function d(h){var m=g[3],r=g[5],l=f(),n=(m-l)*r;if(1>n)uss.stopScrollingY(b,g[11]); -else{try{var u=g[1];var p=g[15]?g[15](n,g[9],h,g[7],l,m,b):g[13](n,g[9],h,g[7],l,m,b);if(u!==g[1])return;if(m!==g[3]){g[1]=window.requestAnimationFrame(d);return}Number.isFinite(p)||(DEFAULT_WARNING_LOGGER(p,"is not a valid step length",!0),p=uss.calcYStepLength(e))}catch(v){p=uss.calcYStepLength(e)}n<=p?(q(m),uss.stopScrollingY(b,g[11])):(q(l+p*r),0!==p&&l===f()?uss.stopScrollingY(b,g[11]):g[1]=window.requestAnimationFrame(d))}}b=void 0===b?uss._pageScroller:b;if(Number.isFinite(a))if(b===window|| -b instanceof HTMLElement)if(1>uss.getMaxScrollY(b))a=b===window?"window":b.tagName.toLowerCase()+(b.id?"#"+b.id:"")+(b.className?"."+b.className:""),DEFAULT_WARNING_LOGGER(a,"is not scrollable on the y-axis",!1),uss.stopScrollingY(b,c);else{var f=uss.getScrollYCalculator(b),e=a-f(),k=0e)uss.stopScrollingY(b,c);else{var q=b!==window?function(h){return b.scrollTop=h}:function(h){return b.scroll(window.scrollX,h)};if(uss._reducedMotion)q(a),uss.stopScrollingY(b,c);else{var t=uss._containersData.get(b), -g=t||[];g[3]=a;g[5]=k;g[7]=e;g[9]=performance.now();g[11]=c;g[1]||(g[1]=window.requestAnimationFrame(d),t||uss._containersData.set(b,g))}}}else DEFAULT_ERROR_LOGGER("scrollYTo","the container to be an HTMLElement or the Window",b);else DEFAULT_ERROR_LOGGER("scrollYTo","the finalYPosition to be a number",a)},scrollXBy:function(a,b,c,d){b=void 0===b?uss._pageScroller:b;d=void 0===d?!0:d;if(Number.isFinite(a))if(b===window||b instanceof HTMLElement){if(!d&&(d=uss._containersData.get(b)||[],d[0])){d[8]= -performance.now();d[10]=c;0!==a&&(d[2]+=a,a=d[2]-uss.getScrollXCalculator(b)(),d[4]=0f?f++:d()}:null;uss.scrollXTo(a,c,e);uss.scrollYTo(b,c,e)}else DEFAULT_ERROR_LOGGER("scrollTo","the container to be an HTMLElement or the Window",c);else DEFAULT_ERROR_LOGGER("scrollTo","the finalYPosition to be a number",b);else DEFAULT_ERROR_LOGGER("scrollTo","the finalXPosition to be a number",a)},scrollBy:function(a,b,c,d,f){c=void 0===c?uss._pageScroller:c;f=void 0===f?!0:f;if(Number.isFinite(a))if(Number.isFinite(b))if(c===window||c instanceof HTMLElement){if(f){f=uss.getScrollXCalculator(c)(); -var e=uss.getScrollYCalculator(c)()}else e=uss._containersData.get(c)||[],f=e[0]?e[2]:uss.getScrollXCalculator(c)(),e=e[1]?e[3]:uss.getScrollYCalculator(c)();uss.scrollTo(f+a,e+b,c,d)}else DEFAULT_ERROR_LOGGER("scrollBy","the container to be an HTMLElement or the Window",c);else DEFAULT_ERROR_LOGGER("scrollBy","the deltaY to be a number",b);else DEFAULT_ERROR_LOGGER("scrollBy","the deltaX to be a number",a)},scrollIntoView:function(a,b,c,d,f){function e(){var r=uss.calcScrollbarsDimensions(h),l=uss.calcBordersDimensions(h), -n=h!==window?h.getBoundingClientRect():{left:0,top:0,width:uss._windowWidth,height:uss._windowHeight},u=n.width,p=n.height,v=m.getBoundingClientRect(),z=v.width,w=v.height,y=v.left-n.left;n=v.top-n.top;if("nearest"===b){v=Math.abs(u-y-z);var x=Math.abs(.5*(u-z)-y);g=(0k?a:q[k-1],e())};0!==u&&0!==r?uss.scrollBy(u,r,h,l):0!==u?uss.scrollXBy(u,h,l):0!==r?uss.scrollYBy(r,h,l):l()}b=void 0===b?!0:b;c=void 0===c?!0:c;f=void 0===f?!1:f;if(a===window)"function"===typeof d&&window.requestAnimationFrame(d);else if(a instanceof HTMLElement){var k=-1,q=uss.getAllScrollableParents(a,f,function(){return k++});if(0>k)"function"===typeof d&&window.requestAnimationFrame(d);else{var t=c,g=b;var h=q[k];var m=1> -k?a:q[k-1];e()}}else DEFAULT_ERROR_LOGGER("scrollIntoView","the container to be an HTMLElement or the Window",a)},scrollIntoViewIfNeeded:function(a,b,c,d){function f(){var m=uss.calcScrollbarsDimensions(g),r=uss.calcBordersDimensions(g),l=g!==window?g.getBoundingClientRect():{left:0,top:0,width:uss._windowWidth,height:uss._windowHeight},n=l.width,u=l.height,p=h.getBoundingClientRect(),v=p.width,z=p.height,w=p.left-l.left;l=p.top-l.top;p=0>=w&&0<=w+v-n+m[0];var y=0>=l&&0<=l+z-u+m[1],x=h===a;p=-1w+v-n+m[0]||x&&p;y=-1l+z-u+m[1]||x&&y;if(p&&y)x?"function"===typeof c&&window.requestAnimationFrame(c):(e--,g=k[e],h=1>e?a:k[e-1],f());else{if(x&&!0===b)y=p=!1;else{if(!p){x=Math.abs(n-w-v);var A=Math.abs(.5*(n-v)-w);t=(0e?a:k[e-1],f())};0!==n&&0!==m?uss.scrollBy(n,m,g,r):0!==n?uss.scrollXBy(n,g,r):0!==m?uss.scrollYBy(m,g,r):r()}}b=void 0===b?!0:b;d=void 0===d?!1:d;if(a===window)"function"===typeof c&&window.requestAnimationFrame(c);else if(a instanceof HTMLElement){var e=-1,k=uss.getAllScrollableParents(a,d,function(){return e++});if(0>e)"function"===typeof c&&window.requestAnimationFrame(c);else{var q=null,t=null;var g=k[e];var h=1>e?a:k[e-1];f()}}else DEFAULT_ERROR_LOGGER("scrollIntoView","the container to be an HTMLElement or the Window", -a)},stopScrollingX:function(a,b){a=void 0===a?uss._pageScroller:a;if(a===window||a instanceof HTMLElement){var c=uss._containersData.get(a)||[];window.cancelAnimationFrame(c[0]);c[0]=null;if(!c[1]){var d=[];c[12]&&(d[12]=c[12]);c[13]&&(d[13]=c[13]);uss._containersData.set(a,d)}"function"===typeof b&&window.requestAnimationFrame(b)}else DEFAULT_ERROR_LOGGER("stopScrollingX","the container to be an HTMLElement or the Window",a)},stopScrollingY:function(a,b){a=void 0===a?uss._pageScroller:a;if(a===window|| -a instanceof HTMLElement){var c=uss._containersData.get(a)||[];window.cancelAnimationFrame(c[1]);c[1]=null;if(!c[1]){var d=[];c[12]&&(d[12]=c[12]);c[13]&&(d[13]=c[13]);uss._containersData.set(a,d)}"function"===typeof b&&window.requestAnimationFrame(b)}else DEFAULT_ERROR_LOGGER("stopScrollingY","the container to be an HTMLElement or the Window",a)},stopScrolling:function(a,b){a=void 0===a?uss._pageScroller:a;if(a===window||a instanceof HTMLElement){var c=uss._containersData.get(a)||[];window.cancelAnimationFrame(c[0]); -window.cancelAnimationFrame(c[1]);c[0]=null;c[1]=null;var d=[];c[12]&&(d[12]=c[12]);c[13]&&(d[13]=c[13]);uss._containersData.set(a,d);"function"===typeof b&&window.requestAnimationFrame(b)}else DEFAULT_ERROR_LOGGER("stopScrolling","the container to be an HTMLElement or the Window",a)},stopScrollingAll:function(a){for(var b=$jscomp.makeIterator(uss._containersData.entries()),c=b.next();!c.done;c=b.next()){var d=$jscomp.makeIterator(c.value);c=d.next().value;d=d.next().value;window.cancelAnimationFrame(d[0]); -window.cancelAnimationFrame(d[1]);d[0]=null;d[1]=null;var f=[];d[12]&&(f[12]=d[12]);d[13]&&(f[13]=d[13]);uss._containersData.set(c,f)}"function"===typeof a&&window.requestAnimationFrame(a)},hrefSetup:function(a,b,c,d,f,e){a=void 0===a?!0:a;b=void 0===b?!0:b;f=void 0===f?!1:f;e=void 0===e?!1:e;var k="function"===typeof c?c:function(){};c=document.URL.split("#")[0];var q=e&&!!(window.history&&window.history.pushState&&window.history.scrollRestoration);q&&(window.history.scrollRestoration="manual",window.addEventListener("popstate", -function(){var h=document.URL.split("#")[1];h?(h=document.getElementById(h)||document.querySelector("a[name='"+h+"']"),null!==h&&!1!==k(window,h)&&uss.scrollIntoView(h,a,b,d,f)):!1!==k(window,uss._pageScroller)&&uss.scrollTo(0,0,uss._pageScroller,d)},{passive:!0}),window.addEventListener("unload",function(h){return h.preventDefault()},{passive:!1,once:!0}));e={};for(var t=$jscomp.makeIterator(document.links),g=t.next();!g.done;e={$jscomp$loop$prop$_pageLink$10:e.$jscomp$loop$prop$_pageLink$10,$jscomp$loop$prop$_elementToReach$11:e.$jscomp$loop$prop$_elementToReach$11, -$jscomp$loop$prop$_pageLinkParts$12:e.$jscomp$loop$prop$_pageLinkParts$12},g=t.next())e.$jscomp$loop$prop$_pageLink$10=g.value,e.$jscomp$loop$prop$_pageLinkParts$12=e.$jscomp$loop$prop$_pageLink$10.href.split("#"),e.$jscomp$loop$prop$_pageLinkParts$12[0]===c&&(""===e.$jscomp$loop$prop$_pageLinkParts$12[1]?e.$jscomp$loop$prop$_pageLink$10.addEventListener("click",function(h){return function(m){m.preventDefault();m.stopPropagation();!1!==k(h.$jscomp$loop$prop$_pageLink$10,uss._pageScroller)&&(q&&"#"!== -window.history.state&&window.history.pushState("#","","#"),uss.scrollTo(0,0,uss._pageScroller,d))}}(e),{passive:!1}):(e.$jscomp$loop$prop$_elementToReach$11=document.getElementById(e.$jscomp$loop$prop$_pageLinkParts$12[1])||document.querySelector("a[name='"+e.$jscomp$loop$prop$_pageLinkParts$12[1]+"']"),null===e.$jscomp$loop$prop$_elementToReach$11?DEFAULT_WARNING_LOGGER(e.$jscomp$loop$prop$_pageLinkParts$12[1],"is not a valid anchor's destination",!0):e.$jscomp$loop$prop$_pageLink$10.addEventListener("click", -function(h){return function(m){m.preventDefault();m.stopPropagation();!1!==k(h.$jscomp$loop$prop$_pageLink$10,h.$jscomp$loop$prop$_elementToReach$11)&&(q&&window.history.state!==h.$jscomp$loop$prop$_pageLinkParts$12[1]&&window.history.pushState(h.$jscomp$loop$prop$_pageLinkParts$12[1],"","#"+h.$jscomp$loop$prop$_pageLinkParts$12[1]),uss.scrollIntoView(h.$jscomp$loop$prop$_elementToReach$11,a,b,d,f))}}(e),{passive:!1})))}}; -window.addEventListener("resize",function(){uss._windowHeight=window.innerHeight;uss._windowWidth=window.innerWidth},{passive:!0});window.addEventListener("load",function(){var a=document.createElement("div");a.style.overflowX="scroll";document.body.appendChild(a);uss._scrollbarsMaxDimension=a.offsetHeight-a.clientHeight;document.body.removeChild(a)},{passive:!0,once:!0}); +uss._xStepLength:Math.ceil(a/uss._minAnimationFrame)},calcYStepLength:function(a){if(!Number.isFinite(a)||0>a)throw DEFAULT_ERROR_LOGGER("calcYStepLength","the deltaY to be a positive number",a),"USS fatal error (execution stopped)";return a>=uss._minAnimationFrame*uss._yStepLength?uss._yStepLength:Math.ceil(a/uss._minAnimationFrame)},calcScrollbarsDimensions:function(a){if(a===window){if(a=document.scrollingElement||uss.getPageScroller(),a===window)return[0,0]}else if(!(a instanceof HTMLElement))throw DEFAULT_ERROR_LOGGER("calcScrollbarsDimensions", +"the element to be an HTMLElement or the Window",a),"USS fatal error (execution stopped)";if(0===uss._scrollbarsMaxDimension)return[0,0];var b=[],c=window.getComputedStyle(a),d=Number.parseInt(c.width),f=Number.parseInt(c.height),e=a.clientWidth,h=a.clientHeight,p=a.style.overflowX,t=a.style.overflowY,g=a.scrollLeft,k=a.scrollTop;a.style.overflowX="hidden";a.style.overflowY="hidden";b[0]=Number.parseInt(c.width)-d;b[1]=Number.parseInt(c.height)-f;0===b[0]?b[0]=a.clientWidth-e:0>b[0]&&(b[0]=0);0=== +b[1]?b[1]=a.clientHeight-h:0>b[1]&&(b[1]=0);a.style.overflowX=p;a.style.overflowY=t;a.scrollLeft=g;a.scrollTop=k;return b},calcBordersDimensions:function(a){if(a===window&&(a=document.scrollingElement||uss.getPageScroller(),a===window))return[0,0,0,0];if(!(a instanceof HTMLElement))throw DEFAULT_ERROR_LOGGER("calcBordersDimensions","the element to be an HTMLElement or the Window",a),"USS fatal error (execution stopped)";a=window.getComputedStyle(a);return[Number.parseInt(a.borderTopWidth),Number.parseInt(a.borderRightWidth), +Number.parseInt(a.borderBottomWidth),Number.parseInt(a.borderLeftWidth)]},getScrollXCalculator:function(a){a=void 0===a?uss._pageScroller:a;return a===window?function(){return window.scrollX}:a instanceof HTMLElement?function(){return a.scrollLeft}:function(){DEFAULT_ERROR_LOGGER("getScrollXCalculator","the container to be an HTMLElement or the Window",a);throw"USS fatal error (execution stopped)";}},getScrollYCalculator:function(a){a=void 0===a?uss._pageScroller:a;return a===window?function(){return window.scrollY}: +a instanceof HTMLElement?function(){return a.scrollTop}:function(){DEFAULT_ERROR_LOGGER("getScrollYCalculator","the container to be an HTMLElement or the Window",a);throw"USS fatal error (execution stopped)";}},getMaxScrollX:function(a){a=void 0===a?uss._pageScroller:a;if(a===window){var b=window.scrollX;a.scroll(1073741824,window.scrollY);var c=window.scrollX;a.scroll(b,window.scrollY);return c}if(a===document.documentElement||a===document.body)return b=a.scrollLeft,a.scrollLeft=1073741824,c=a.scrollLeft, +a.scrollLeft=b,c;if(a instanceof HTMLElement)return a.scrollWidth-a.clientWidth;DEFAULT_ERROR_LOGGER("getMaxScrollX","the container to be an HTMLElement or the Window",a)},getMaxScrollY:function(a){a=void 0===a?uss._pageScroller:a;if(a===window){var b=window.scrollY;a.scroll(window.scrollX,1073741824);var c=window.scrollY;a.scroll(window.scrollX,b);return c}if(a===document.documentElement||a===document.body)return b=a.scrollTop,a.scrollTop=1073741824,c=a.scrollTop,a.scrollTop=b,c;if(a instanceof HTMLElement)return a.scrollHeight- +a.clientHeight;DEFAULT_ERROR_LOGGER("getMaxScrollY","the container to be an HTMLElement or the Window",a)},getXScrollableParent:function(a,b){b=void 0===b?!1:b;if(a===window)return null;if(!(a instanceof HTMLElement))return DEFAULT_ERROR_LOGGER("getXScrollableParent","the element to be an HTMLElement or the Window",a),null;var c=b?/(auto|scroll|hidden|visible)/:/(auto|scroll|visible)/,d=document.documentElement,f=document.body;if(a===f){if(c.test(window.getComputedStyle(d).overflowX)&&1<=uss.getMaxScrollX(d))return d; +a=d}if(a===d)return 1<=uss.getMaxScrollX(window)?window:null;var e=window.getComputedStyle(a);if("fixed"===e.position)return null;var h=b?/(auto|scroll|hidden)/:/(auto|scroll)/,p="absolute"!==e.position;do{a=a.parentElement;e=window.getComputedStyle(a);if(a===f)break;if((p||"static"!==e.position)&&a.scrollWidth>a.clientWidth&&h.test(e.overflowX))return a;if("fixed"===e.position)return null}while(1);return c.test(e.overflowX)&&1<=uss.getMaxScrollX(f)?f:c.test(window.getComputedStyle(d).overflowX)&& +1<=uss.getMaxScrollX(d)?d:1<=uss.getMaxScrollX(window)?window:null},getYScrollableParent:function(a,b){b=void 0===b?!1:b;if(a===window)return null;if(!(a instanceof HTMLElement))return DEFAULT_ERROR_LOGGER("getYScrollableParent","the element to be an HTMLElement or the Window",a),null;var c=b?/(auto|scroll|hidden|visible)/:/(auto|scroll|visible)/,d=document.documentElement,f=document.body;if(a===f){if(c.test(window.getComputedStyle(d).overflowY)&&1<=uss.getMaxScrollY(d))return d;a=d}if(a===d)return 1<= +uss.getMaxScrollY(window)?window:null;var e=window.getComputedStyle(a);if("fixed"===e.position)return null;var h=b?/(auto|scroll|hidden)/:/(auto|scroll)/,p="absolute"!==e.position;do{a=a.parentElement;e=window.getComputedStyle(a);if(a===f)break;if((p||"static"!==e.position)&&a.scrollHeight>a.clientHeight&&h.test(e.overflowY))return a;if("fixed"===e.position)return null}while(1);return c.test(e.overflowY)&&1<=uss.getMaxScrollY(f)?f:c.test(window.getComputedStyle(d).overflowY)&&1<=uss.getMaxScrollY(d)? +d:1<=uss.getMaxScrollY(window)?window:null},getScrollableParent:function(a,b){b=void 0===b?!1:b;if(a===window)return null;if(!(a instanceof HTMLElement))return DEFAULT_ERROR_LOGGER("getScrollableParent","the element to be an HTMLElement or the Window",a),null;var c=b?/(auto|scroll|hidden|visible)/:/(auto|scroll|visible)/,d=document.documentElement,f=document.body,e=function(g){return 1<=uss.getMaxScrollX(g)||1<=uss.getMaxScrollY(g)};if(a===f){if(c.test(window.getComputedStyle(d).overflow)&&e(d))return d; +a=d}if(a===d)return e(window)?window:null;var h=window.getComputedStyle(a);if("fixed"===h.position)return null;var p=b?/(auto|scroll|hidden)/:/(auto|scroll)/,t="absolute"!==h.position;do{a=a.parentElement;h=window.getComputedStyle(a);if(a===f)break;if((t||"static"!==h.position)&&(a.scrollWidth>a.clientWidth||a.scrollHeight>a.clientHeight)&&p.test(h.overflow))return a;if("fixed"===h.position)return null}while(1);return c.test(h.overflow)&&e(f)?f:c.test(window.getComputedStyle(d).overflow)&&e(d)?d: +e(window)?window:null},getAllScrollableParents:function(a,b,c){b=void 0===b?!1:b;if(a===window)return[];if(!(a instanceof HTMLElement))return DEFAULT_ERROR_LOGGER("getAllScrollableParents","the element to be an HTMLElement or the Window",a),[];var d=b?/(auto|scroll|hidden|visible)/:/(auto|scroll|visible)/,f=document.documentElement,e=document.body,h=[],p="function"===typeof c?c:function(){};c=function(l){return 1<=uss.getMaxScrollX(l)||1<=uss.getMaxScrollY(l)};var t=function(l){h.push(l);p(l)};a=== +e&&(d.test(window.getComputedStyle(f).overflow)&&c(f)&&t(f),a=f);if(a===f)return c(window)&&t(window),h;var g=window.getComputedStyle(a);if("fixed"===g.position)return h;b=b?/(auto|scroll|hidden)/:/(auto|scroll)/;var k="absolute"!==g.position;do{a=a.parentElement;g=window.getComputedStyle(a);if(a===e)break;(k||"static"!==g.position)&&(a.scrollWidth>a.clientWidth||a.scrollHeight>a.clientHeight)&&b.test(g.overflow)&&t(a);if("fixed"===g.position)return h}while(1);d.test(g.overflow)&&c(e)&&t(e);d.test(window.getComputedStyle(f).overflow)&& +c(f)&&t(f);c(window)&&t(window);return h},scrollXTo:function(a,b,c){function d(k){var l=g[2],r=g[4],m=f(),n=(l-m)*r;if(1>n)uss.stopScrollingX(b,g[10]);else{try{var u=g[0];var q=g[14]?g[14](n,g[8],k,g[6],m,l,b):g[12](n,g[8],k,g[6],m,l,b);if(u!==g[0])return;if(l!==g[2]){g[0]=window.requestAnimationFrame(d);return}Number.isFinite(q)||(DEFAULT_WARNING_LOGGER(q,"is not a valid step length",!0),q=uss.calcXStepLength(e))}catch(v){q=uss.calcXStepLength(e)}n<=q?(p(l),uss.stopScrollingX(b,g[10])):(p(m+q*r), +0!==q&&m===f()?uss.stopScrollingX(b,g[10]):g[0]=window.requestAnimationFrame(d))}}b=void 0===b?uss._pageScroller:b;if(Number.isFinite(a))if(b===window||b instanceof HTMLElement)if(1>uss.getMaxScrollX(b))a=b===window?"window":b.tagName.toLowerCase()+(b.id?"#"+b.id:"")+(b.className?"."+b.className:""),DEFAULT_WARNING_LOGGER(a,"is not scrollable on the x-axis",!1),uss.stopScrollingX(b,c);else{var f=uss.getScrollXCalculator(b),e=a-f(),h=0e)uss.stopScrollingX(b,c);else{var p=b!==window? +function(k){return b.scrollLeft=k}:function(k){return b.scroll(k,window.scrollY)};if(uss._reducedMotion)p(a),uss.stopScrollingX(b,c);else{var t=uss._containersData.get(b),g=t||[];g[2]=a;g[4]=h;g[6]=e;g[8]=performance.now();g[10]=c;g[0]||(g[0]=window.requestAnimationFrame(d),t||uss._containersData.set(b,g))}}}else DEFAULT_ERROR_LOGGER("scrollXTo","the container to be an HTMLElement or the Window",b);else DEFAULT_ERROR_LOGGER("scrollXTo","the finalXPosition to be a number",a)},scrollYTo:function(a, +b,c){function d(k){var l=g[3],r=g[5],m=f(),n=(l-m)*r;if(1>n)uss.stopScrollingY(b,g[11]);else{try{var u=g[1];var q=g[15]?g[15](n,g[9],k,g[7],m,l,b):g[13](n,g[9],k,g[7],m,l,b);if(u!==g[1])return;if(l!==g[3]){g[1]=window.requestAnimationFrame(d);return}Number.isFinite(q)||(DEFAULT_WARNING_LOGGER(q,"is not a valid step length",!0),q=uss.calcYStepLength(e))}catch(v){q=uss.calcYStepLength(e)}n<=q?(p(l),uss.stopScrollingY(b,g[11])):(p(m+q*r),0!==q&&m===f()?uss.stopScrollingY(b,g[11]):g[1]=window.requestAnimationFrame(d))}} +b=void 0===b?uss._pageScroller:b;if(Number.isFinite(a))if(b===window||b instanceof HTMLElement)if(1>uss.getMaxScrollY(b))a=b===window?"window":b.tagName.toLowerCase()+(b.id?"#"+b.id:"")+(b.className?"."+b.className:""),DEFAULT_WARNING_LOGGER(a,"is not scrollable on the y-axis",!1),uss.stopScrollingY(b,c);else{var f=uss.getScrollYCalculator(b),e=a-f(),h=0e)uss.stopScrollingY(b,c);else{var p=b!==window?function(k){return b.scrollTop=k}:function(k){return b.scroll(window.scrollX,k)}; +if(uss._reducedMotion)p(a),uss.stopScrollingY(b,c);else{var t=uss._containersData.get(b),g=t||[];g[3]=a;g[5]=h;g[7]=e;g[9]=performance.now();g[11]=c;g[1]||(g[1]=window.requestAnimationFrame(d),t||uss._containersData.set(b,g))}}}else DEFAULT_ERROR_LOGGER("scrollYTo","the container to be an HTMLElement or the Window",b);else DEFAULT_ERROR_LOGGER("scrollYTo","the finalYPosition to be a number",a)},scrollXBy:function(a,b,c,d){b=void 0===b?uss._pageScroller:b;d=void 0===d?!0:d;if(Number.isFinite(a))if(b=== +window||b instanceof HTMLElement){if(!d&&(d=uss._containersData.get(b)||[],d[0])){d[8]=performance.now();d[10]=c;0!==a&&(d[2]+=a,a=d[2]-uss.getScrollXCalculator(b)(),d[4]=0f?f++:d()}:null;uss.scrollXTo(a,c,e);uss.scrollYTo(b,c,e)}else DEFAULT_ERROR_LOGGER("scrollTo","the container to be an HTMLElement or the Window",c);else DEFAULT_ERROR_LOGGER("scrollTo","the finalYPosition to be a number",b);else DEFAULT_ERROR_LOGGER("scrollTo","the finalXPosition to be a number",a)},scrollBy:function(a,b,c,d,f){c=void 0===c?uss._pageScroller:c;f=void 0===f?!0:f;if(Number.isFinite(a))if(Number.isFinite(b))if(c=== +window||c instanceof HTMLElement){if(f){f=uss.getScrollXCalculator(c)();var e=uss.getScrollYCalculator(c)()}else e=uss._containersData.get(c)||[],f=e[0]?e[2]:uss.getScrollXCalculator(c)(),e=e[1]?e[3]:uss.getScrollYCalculator(c)();uss.scrollTo(f+a,e+b,c,d)}else DEFAULT_ERROR_LOGGER("scrollBy","the container to be an HTMLElement or the Window",c);else DEFAULT_ERROR_LOGGER("scrollBy","the deltaY to be a number",b);else DEFAULT_ERROR_LOGGER("scrollBy","the deltaX to be a number",a)},scrollIntoView:function(a, +b,c,d,f){function e(){var r=uss.calcScrollbarsDimensions(k),m=uss.calcBordersDimensions(k),n=k!==window?k.getBoundingClientRect():{left:0,top:0,width:uss._windowWidth,height:uss._windowHeight},u=n.width,q=n.height,v=l.getBoundingClientRect(),z=v.width,w=v.height,y=v.left-n.left;n=v.top-n.top;if("nearest"===b){v=Math.abs(u-y-z);var x=Math.abs(.5*(u-z)-y);g=(0h?a:p[h-1],e())};0!==u&&0!==r?uss.scrollBy(u,r,k,m):0!==u?uss.scrollXBy(u,k,m):0!==r?uss.scrollYBy(r,k,m):m()}b=void 0===b?!0:b;c=void 0===c?!0:c;f=void 0===f?!1:f;if(a===window)"function"===typeof d&&window.requestAnimationFrame(d);else if(a instanceof HTMLElement){var h=-1,p=uss.getAllScrollableParents(a,f,function(){return h++});if(0>h)"function"=== +typeof d&&window.requestAnimationFrame(d);else{var t=c,g=b,k=p[h],l=p[h-1];k!==window||l!==document.body&&l!==document.documentElement||(h--,p[h]=window);l=1>h?a:p[h-1];e()}}else DEFAULT_ERROR_LOGGER("scrollIntoView","the container to be an HTMLElement or the Window",a)},scrollIntoViewIfNeeded:function(a,b,c,d){function f(){var l=uss.calcScrollbarsDimensions(g),r=uss.calcBordersDimensions(g),m=g!==window?g.getBoundingClientRect():{left:0,top:0,width:uss._windowWidth,height:uss._windowHeight},n=m.width, +u=m.height,q=k.getBoundingClientRect(),v=q.width,z=q.height,w=q.left-m.left;m=q.top-m.top;q=0>=w&&0<=w+v-n+l[0];var y=0>=m&&0<=m+z-u+l[1],x=k===a;q=-1w+v-n+l[0]||x&&q;y=-1m+z-u+l[1]||x&&y;if(q&&y)x?"function"===typeof c&&window.requestAnimationFrame(c):(e--,g=h[e],k=1>e?a:h[e-1],f());else{if(x&&!0===b)y=q=!1;else{if(!q){x=Math.abs(n-w-v);var A=Math.abs(.5*(n-v)-w);t=(0e?a:h[e-1],f())};0!==n&&0!==l?uss.scrollBy(n,l,g,r):0!==n?uss.scrollXBy(n,g,r):0!==l?uss.scrollYBy(l,g,r):r()}}b=void 0===b?!0:b;d=void 0===d?!1:d;if(a===window)"function"===typeof c&&window.requestAnimationFrame(c);else if(a instanceof HTMLElement){var e=-1,h=uss.getAllScrollableParents(a,d,function(){return e++});if(0> +e)"function"===typeof c&&window.requestAnimationFrame(c);else{var p=null,t=null,g=h[e],k=h[e-1];g!==window||k!==document.body&&k!==document.documentElement||(e--,h[e]=window);k=1>e?a:h[e-1];f()}}else DEFAULT_ERROR_LOGGER("scrollIntoView","the container to be an HTMLElement or the Window",a)},stopScrollingX:function(a,b){a=void 0===a?uss._pageScroller:a;if(a===window||a instanceof HTMLElement){var c=uss._containersData.get(a)||[];window.cancelAnimationFrame(c[0]);c[0]=null;if(!c[1]){var d=[];c[12]&& +(d[12]=c[12]);c[13]&&(d[13]=c[13]);uss._containersData.set(a,d)}"function"===typeof b&&window.requestAnimationFrame(b)}else DEFAULT_ERROR_LOGGER("stopScrollingX","the container to be an HTMLElement or the Window",a)},stopScrollingY:function(a,b){a=void 0===a?uss._pageScroller:a;if(a===window||a instanceof HTMLElement){var c=uss._containersData.get(a)||[];window.cancelAnimationFrame(c[1]);c[1]=null;if(!c[1]){var d=[];c[12]&&(d[12]=c[12]);c[13]&&(d[13]=c[13]);uss._containersData.set(a,d)}"function"=== +typeof b&&window.requestAnimationFrame(b)}else DEFAULT_ERROR_LOGGER("stopScrollingY","the container to be an HTMLElement or the Window",a)},stopScrolling:function(a,b){a=void 0===a?uss._pageScroller:a;if(a===window||a instanceof HTMLElement){var c=uss._containersData.get(a)||[];window.cancelAnimationFrame(c[0]);window.cancelAnimationFrame(c[1]);c[0]=null;c[1]=null;var d=[];c[12]&&(d[12]=c[12]);c[13]&&(d[13]=c[13]);uss._containersData.set(a,d);"function"===typeof b&&window.requestAnimationFrame(b)}else DEFAULT_ERROR_LOGGER("stopScrolling", +"the container to be an HTMLElement or the Window",a)},stopScrollingAll:function(a){for(var b=$jscomp.makeIterator(uss._containersData.entries()),c=b.next();!c.done;c=b.next()){var d=$jscomp.makeIterator(c.value);c=d.next().value;d=d.next().value;window.cancelAnimationFrame(d[0]);window.cancelAnimationFrame(d[1]);d[0]=null;d[1]=null;var f=[];d[12]&&(f[12]=d[12]);d[13]&&(f[13]=d[13]);uss._containersData.set(c,f)}"function"===typeof a&&window.requestAnimationFrame(a)},hrefSetup:function(a,b,c,d,f,e){a= +void 0===a?!0:a;b=void 0===b?!0:b;f=void 0===f?!1:f;e=void 0===e?!1:e;var h="function"===typeof c?c:function(){};c=document.URL.split("#")[0];var p=e&&!!(window.history&&window.history.pushState&&window.history.scrollRestoration);p&&(window.history.scrollRestoration="manual",window.addEventListener("popstate",function(){var k=document.URL.split("#")[1];k?(k=document.getElementById(k)||document.querySelector("a[name='"+k+"']"),null!==k&&!1!==h(window,k)&&uss.scrollIntoView(k,a,b,d,f)):!1!==h(window, +uss._pageScroller)&&uss.scrollTo(0,0,uss._pageScroller,d)},{passive:!0}),window.addEventListener("unload",function(k){return k.preventDefault()},{passive:!1,once:!0}));e={};for(var t=$jscomp.makeIterator(document.links),g=t.next();!g.done;e={$jscomp$loop$prop$_pageLink$10:e.$jscomp$loop$prop$_pageLink$10,$jscomp$loop$prop$_elementToReach$11:e.$jscomp$loop$prop$_elementToReach$11,$jscomp$loop$prop$_pageLinkParts$12:e.$jscomp$loop$prop$_pageLinkParts$12},g=t.next())e.$jscomp$loop$prop$_pageLink$10= +g.value,e.$jscomp$loop$prop$_pageLinkParts$12=e.$jscomp$loop$prop$_pageLink$10.href.split("#"),e.$jscomp$loop$prop$_pageLinkParts$12[0]===c&&(""===e.$jscomp$loop$prop$_pageLinkParts$12[1]?e.$jscomp$loop$prop$_pageLink$10.addEventListener("click",function(k){return function(l){l.preventDefault();l.stopPropagation();!1!==h(k.$jscomp$loop$prop$_pageLink$10,uss._pageScroller)&&(p&&"#"!==window.history.state&&window.history.pushState("#","","#"),uss.scrollTo(0,0,uss._pageScroller,d))}}(e),{passive:!1}): +(e.$jscomp$loop$prop$_elementToReach$11=document.getElementById(e.$jscomp$loop$prop$_pageLinkParts$12[1])||document.querySelector("a[name='"+e.$jscomp$loop$prop$_pageLinkParts$12[1]+"']"),null===e.$jscomp$loop$prop$_elementToReach$11?DEFAULT_WARNING_LOGGER(e.$jscomp$loop$prop$_pageLinkParts$12[1],"is not a valid anchor's destination",!0):e.$jscomp$loop$prop$_pageLink$10.addEventListener("click",function(k){return function(l){l.preventDefault();l.stopPropagation();!1!==h(k.$jscomp$loop$prop$_pageLink$10, +k.$jscomp$loop$prop$_elementToReach$11)&&(p&&window.history.state!==k.$jscomp$loop$prop$_pageLinkParts$12[1]&&window.history.pushState(k.$jscomp$loop$prop$_pageLinkParts$12[1],"","#"+k.$jscomp$loop$prop$_pageLinkParts$12[1]),uss.scrollIntoView(k.$jscomp$loop$prop$_elementToReach$11,a,b,d,f))}}(e),{passive:!1})))}};window.addEventListener("resize",function(){uss._windowHeight=window.innerHeight;uss._windowWidth=window.innerWidth},{passive:!0}); +window.addEventListener("load",function(){var a=document.createElement("div");a.style.overflowX="scroll";document.body.appendChild(a);uss._scrollbarsMaxDimension=a.offsetHeight-a.clientHeight;document.body.removeChild(a)},{passive:!0,once:!0}); try{window.matchMedia("(prefers-reduced-motion)").addEventListener("change",function(){uss._reducedMotion=!uss._reducedMotion;uss.stopScrollingAll()},{passive:!0})}catch(a){window.matchMedia("(prefers-reduced-motion)").addListener(function(){uss._reducedMotion=!uss._reducedMotion;uss.stopScrollingAll()},{passive:!0})}; \ No newline at end of file From 4e58be2a8ac0e71a81cab4bcf6dcc6c989a38ce1 Mon Sep 17 00:00:00 2001 From: Cristian Davide Conte <64142998+CristianDavideConte@users.noreply.github.com> Date: Thu, 19 May 2022 15:15:02 +0200 Subject: [PATCH 30/30] fixed typos in tests' descriptions --- cypress/integration/x-axis-getters-tests.js | 4 ++-- cypress/integration/y-axis-getters-tests.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cypress/integration/x-axis-getters-tests.js b/cypress/integration/x-axis-getters-tests.js index 264df38..6597d64 100644 --- a/cypress/integration/x-axis-getters-tests.js +++ b/cypress/integration/x-axis-getters-tests.js @@ -32,7 +32,7 @@ describe("getFinalXPosition-Body", function() { describe("getScrollXDirection-Body", function() { var uss; var scrollYDirectionLeft, scrollYDirectionRight; - it("Checks the getFinalXPosition method", function(){ + it("Checks the getScrollXDirection method", function(){ cy.visit(testSite) cy.window() .then((win) => { @@ -109,7 +109,7 @@ describe("getXStepLength-Body", function() { describe("getMaxScrollX-Body", function() { var uss; - it("Checks the getXStepLength method", function(){ + it("Checks the getMaxScrollX method", function(){ cy.visit(testSite) cy.window() .then((win) => { diff --git a/cypress/integration/y-axis-getters-tests.js b/cypress/integration/y-axis-getters-tests.js index b22cd8a..fec3e93 100644 --- a/cypress/integration/y-axis-getters-tests.js +++ b/cypress/integration/y-axis-getters-tests.js @@ -32,7 +32,7 @@ describe("getFinalYPosition-Body", function() { describe("getScrollYDirection-Body", function() { var uss; var scrollYDirectionUp, scrollYDirectionDown; - it("Checks the getFinalYPosition method", function(){ + it("Checks the getScrollYDirection method", function(){ cy.visit(testSite) cy.window() .then((win) => { @@ -109,7 +109,7 @@ describe("getYStepLength-Body", function() { describe("getMaxScrollY-Body", function() { var uss; - it("Checks the getYStepLength method", function(){ + it("Checks the getMaxScrollY method", function(){ cy.visit(testSite) cy.window() .then((win) => {