Created
January 9, 2023 14:25
-
-
Save MeRahulAhire/cb2cfc97e96364c04ed598124e6d05c9 to your computer and use it in GitHub Desktop.
NasaBlackMarble alternate faulty scroll logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let afghanistan = true; | |
| let iceland = true; | |
| let argentina = true; | |
| let argentina2 = true | |
| let russia = true; | |
| let australia = true; | |
| let usa = true; | |
| let egypt = true; | |
| let pakistan = true; | |
| let india = true; | |
| let india2 = true | |
| let china = true; | |
| let china2 = true | |
| let africa = true; | |
| let korea = true; | |
| let yemen = true; | |
| let yemen2 = true | |
| let syria = true; | |
| let syria2 = true; | |
| scroll.addEventListener("end", () => { | |
| let scrollPosition = window.scrollY / window.innerHeight * 100; | |
| console.log(Math.round(scrollPosition), scrollDirection) | |
| if(scrollDirection === 'up'){ | |
| if (scrollPosition > 75 && scrollPosition < 175 && afghanistan) { // Afghanistan (default height for all is 100vh or 1 scrollposition) | |
| cameraTime(2, 2); | |
| afghanistan = false | |
| } | |
| if (scrollPosition > 175 && scrollPosition < 275 && iceland) { // Iceland | |
| cameraTime(3, 1); | |
| iceland = false; | |
| afghanistan = false; | |
| // baseMapAddress.current = 'assets/img/nasaBlackMarble/sample2.webp' | |
| } | |
| if (scrollPosition > 275 && scrollPosition < 375 && argentina) { // Argentina - 2 scrollPosition | |
| cameraTime(6, 3); | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if(scrollPosition > 375 && scrollPosition < 475 && argentina2){ | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if (scrollPosition > 475 && scrollPosition < 575 && russia) { // Russia | |
| cameraTime(9, 3); | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if (scrollPosition > 575 && scrollPosition < 675 && australia) { // Australia | |
| cameraTime(12, 3); | |
| australia = false; | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if (scrollPosition > 675 && scrollPosition < 775 && usa) { // USA | |
| cameraTime(14, 2); | |
| usa = false; | |
| australia = false; | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if (scrollPosition > 775 && scrollPosition < 875 && egypt) { // Egypt | |
| cameraTime(16, 2); | |
| egypt = false; | |
| usa = false; | |
| australia = false; | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if (scrollPosition > 875 && scrollPosition < 975 && pakistan) { // Pakistan | |
| cameraTime(18, 2); | |
| pakistan = false; | |
| egypt = false; | |
| usa = false; | |
| australia = false; | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if (scrollPosition > 975 && scrollPosition < 1075 && india) { // India - 2 scrollPosition | |
| cameraTime(19, 1); | |
| india = false; | |
| pakistan = false; | |
| egypt = false; | |
| usa = false; | |
| australia = false; | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if (scrollPosition > 1075 && scrollPosition < 1175 && india2){ | |
| india2 = false | |
| india = false; | |
| pakistan = false; | |
| egypt = false; | |
| usa = false; | |
| australia = false; | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if (scrollPosition > 1175 && scrollPosition < 1275 && china) { // China - 2 scrollPosition | |
| cameraTime(20, 1); | |
| china = false; | |
| india2 = false | |
| india = false; | |
| pakistan = false; | |
| egypt = false; | |
| usa = false; | |
| australia = false; | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if(scrollPosition > 1275 && scrollPosition < 1375 && china2){ | |
| china2 = false | |
| china = false; | |
| india2 = false | |
| india = false; | |
| pakistan = false; | |
| egypt = false; | |
| usa = false; | |
| australia = false; | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if (scrollPosition > 1375 && scrollPosition < 1475 && africa) { // Africa | |
| cameraTime(22, 2); | |
| africa = false; | |
| china2 = false | |
| china = false; | |
| india2 = false | |
| india = false; | |
| pakistan = false; | |
| egypt = false; | |
| usa = false; | |
| australia = false; | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if (scrollPosition > 1475 && scrollPosition < 1575 && korea) { // Korea | |
| cameraTime(24, 2); | |
| korea = false; | |
| africa = false; | |
| china2 = false | |
| china = false; | |
| india2 = false | |
| india = false; | |
| pakistan = false; | |
| egypt = false; | |
| usa = false; | |
| australia = false; | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if (scrollPosition > 1575 && scrollPosition < 1675 && yemen) { // Yemen - 2 scrollPosition | |
| cameraTime(26, 2); | |
| yemen = false; | |
| korea = false; | |
| africa = false; | |
| china2 = false | |
| china = false; | |
| india2 = false | |
| india = false; | |
| pakistan = false; | |
| egypt = false; | |
| usa = false; | |
| australia = false; | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if (scrollPosition > 1675 && scrollPosition < 1775 && yemen2){ | |
| yemen2 = false | |
| yemen = false; | |
| korea = false; | |
| africa = false; | |
| china2 = false | |
| china = false; | |
| india2 = false | |
| india = false; | |
| pakistan = false; | |
| egypt = false; | |
| usa = false; | |
| australia = false; | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if (scrollPosition > 1775 && scrollPosition < 1875 && syria) { // Syria - 2 scrollPosition | |
| cameraTime(27, 1); | |
| syria = false; | |
| yemen2 = false | |
| yemen = false; | |
| korea = false; | |
| africa = false; | |
| china2 = false | |
| china = false; | |
| india2 = false | |
| india = false; | |
| pakistan = false; | |
| egypt = false; | |
| usa = false; | |
| australia = false; | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| if (scrollPosition > 1875 && scrollPosition < 2000 && syria2){ | |
| syria2 = false | |
| syria = false; | |
| yemen2 = false | |
| yemen = false; | |
| korea = false; | |
| africa = false; | |
| china2 = false | |
| china = false; | |
| india2 = false | |
| india = false; | |
| pakistan = false; | |
| egypt = false; | |
| usa = false; | |
| australia = false; | |
| russia = false; | |
| argentina2 = false | |
| argentina = false; | |
| iceland = false; | |
| afghanistan = false; | |
| } | |
| } | |
| if(scrollDirection === 'down'){ | |
| if (scrollPosition > 1799 && scrollPosition < 1899 && !syria2){ | |
| syria2 = true; | |
| } | |
| if(scrollPosition > 1699 && scrollPosition < 1799 && !syria){ | |
| cameraTime(26, 1); | |
| syria = true; | |
| syria2 = true | |
| } | |
| if(scrollPosition > 1599 && scrollPosition < 1699 && !yemen2){ | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if (scrollPosition > 1499 && scrollPosition < 1599 && !yemen) { // Yemen - 2 scrollPosition | |
| cameraTime(24, 2); | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if (scrollPosition > 1399 && scrollPosition < 1499 && !korea) { // Korea | |
| cameraTime(22, 2); | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if (scrollPosition > 1299 && scrollPosition < 1399 && !africa) { // Africa | |
| cameraTime(20, 2); | |
| africa = true; | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if (scrollPosition > 1199 && scrollPosition < 1299 && !china2) { // China - 2 scrollPosition | |
| china2 = true | |
| africa = true; | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if (scrollPosition > 1099 && scrollPosition < 1199 && !china) { // China - 2 scrollPosition | |
| cameraTime(19, 1); | |
| china = true; | |
| china2 = true | |
| africa = true; | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if (scrollPosition > 999 && scrollPosition < 1099 && !india2) { // India - 2 scrollPosition | |
| india2 = true | |
| china = true; | |
| china2 = true | |
| africa = true; | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if(scrollPosition > 899 && scrollPosition < 999 && !india){ | |
| cameraTime(18, 1); | |
| india = true; | |
| india2 = true | |
| china = true; | |
| china2 = true | |
| africa = true; | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if(scrollPosition > 799 && scrollPosition < 899 && !pakistan){ | |
| cameraTime(16, 2); | |
| pakistan = true; | |
| india = true; | |
| india2 = true | |
| china = true; | |
| china2 = true | |
| africa = true; | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if(scrollPosition > 699 && scrollPosition < 799 && !egypt){ | |
| cameraTime(14, 2); | |
| egypt = true; | |
| pakistan = true; | |
| india = true; | |
| india2 = true | |
| china = true; | |
| china2 = true | |
| africa = true; | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if(scrollPosition > 599 && scrollPosition < 699 && !usa){ | |
| cameraTime(12, 2); | |
| usa = true; | |
| egypt = true; | |
| pakistan = true; | |
| india = true; | |
| india2 = true | |
| china = true; | |
| china2 = true | |
| africa = true; | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if(scrollPosition > 499 && scrollPosition < 599 && !australia){ | |
| cameraTime(8, 4); | |
| australia = true; | |
| usa = true; | |
| egypt = true; | |
| pakistan = true; | |
| india = true; | |
| india2 = true | |
| china = true; | |
| china2 = true | |
| africa = true; | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if(scrollPosition > 399 && scrollPosition < 499 && !russia){ | |
| cameraTime(6, 2); | |
| russia = true; | |
| australia = true; | |
| usa = true; | |
| egypt = true; | |
| pakistan = true; | |
| india = true; | |
| india2 = true | |
| china = true; | |
| china2 = true | |
| africa = true; | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if(scrollPosition > 299 && scrollPosition < 399 && !argentina2){ | |
| // windowScrollTo(3); | |
| argentina2 = true | |
| russia = true; | |
| australia = true; | |
| usa = true; | |
| egypt = true; | |
| pakistan = true; | |
| india = true; | |
| india2 = true | |
| china = true; | |
| china2 = true | |
| africa = true; | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if(scrollPosition > 199 && scrollPosition < 299 && !argentina){ | |
| cameraTime(3, 3); | |
| argentina = true; | |
| argentina2 = true | |
| russia = true; | |
| australia = true; | |
| usa = true; | |
| egypt = true; | |
| pakistan = true; | |
| india = true; | |
| india2 = true | |
| china = true; | |
| china2 = true | |
| africa = true; | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| if(scrollPosition > 99 && scrollPosition < 199 && !iceland){ | |
| cameraTime(2, 1); | |
| iceland = true; | |
| argentina = true; | |
| argentina2 = true | |
| russia = true; | |
| australia = true; | |
| usa = true; | |
| egypt = true; | |
| pakistan = true; | |
| india = true; | |
| india2 = true | |
| china = true; | |
| china2 = true | |
| africa = true; | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| // if (scrollPosition > 99 && scrollPosition < 199 && !afghanistan) { // Afghanistan | |
| // // cameraTime(2, 1); | |
| // iceland = true; | |
| // argentina = true; | |
| // russia = true; | |
| // australia = true; | |
| // usa = true; | |
| // egypt = true; | |
| // pakistan = true; | |
| // india = true; | |
| // china = true; | |
| // africa = true; | |
| // korea = true; | |
| // yemen = true; | |
| // syria = true; | |
| // } | |
| if (scrollPosition < 25) { // Start | |
| // cameraTime(0, 2); | |
| afghanistan = true; | |
| iceland = true; | |
| argentina = true; | |
| argentina2 = true | |
| russia = true; | |
| australia = true; | |
| usa = true; | |
| egypt = true; | |
| pakistan = true; | |
| india = true; | |
| india2 = true | |
| china = true; | |
| china2 = true | |
| africa = true; | |
| korea = true; | |
| yemen = true; | |
| yemen2 = true | |
| syria = true; | |
| syria2 = true; | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment