Skip to content

Commit

Permalink
Merge pull request #52 from Valik3201/feat/scrollUp
Browse files Browse the repository at this point in the history
scroll Up
  • Loading branch information
Valik3201 committed Jan 3, 2024
2 parents 43db8ab + 7557335 commit a59c468
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 4 deletions.
21 changes: 20 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"axios": "^1.6.2",
"lazysizes": "^5.3.2",
"firebase": "^10.7.1",
"notiflix": "^3.2.6"
"notiflix": "^3.2.6",
"swiper": "^11.0.5"
}
}
2 changes: 2 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<!-- Plik HTML zawierający kod dla modalnego okna z informacjami o książce -->
<include src="./partials/modals/book-popup.html"></include>

<button id="scrollUp"><svg width="20px" height="20px"><use href="/src/images/icons.svg#icon-scroll-up"></use></svg></button>

<!-- Skrypt -->
<script src="./js/common.js" type="module"></script>
<script src="./js/indexModules.js" type="module"></script>
Expand Down
3 changes: 3 additions & 0 deletions src/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ import './charityData.js';
import './mobileMenu.js';
import './darkMode.js';
import './auth.js';
import './scrollUp.js';

import 'lazysizes';
import 'lazysizes/plugins/attrchange/ls.attrchange';

16 changes: 16 additions & 0 deletions src/js/scrollUp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const button = document.querySelector('#scrollUp');

function scrollUp() {
window.scrollTo(0, 0);
}

function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
button.style.display = 'block';
} else {
button.style.display = 'none';
}
}

button.addEventListener('click', scrollUp);
document.addEventListener('scroll', scrollFunction);
22 changes: 21 additions & 1 deletion src/partials/home/home-foundation-slider.html
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
<div class="foundation-list"></div>
<div class="foundation-list">
<div class="swiper">
<!-- Additional required wrapper -->
<div class="swiper-wrapper">
<!-- Slides -->
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
...
</div>
<!-- If we need pagination -->
<div class="swiper-pagination"></div>

<!-- If we need navigation buttons -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>

<!-- If we need scrollbar -->
<div class="swiper-scrollbar"></div>
</div>
</div>
2 changes: 2 additions & 0 deletions src/shopping-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<include src="./partials/shopping-list/shopping-list-main.html"></include>
</main>

<button id="scrollUp" onclick="scrollUp()">Scroll Up</button>

<!-- Skrypt -->
<script src="./js/common.js" type="module"></script>
<script src="./js/shoppingListModules.js" type="module"></script>
Expand Down
38 changes: 38 additions & 0 deletions src/style/scss/_scrollUp.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#scrollUp {
z-index: 1000;
cursor: pointer;
width: 50px;
height: 50px;
opacity: 0.7;
fill: #000;

background-color: #fcfcfc;
border: none;
border-radius: 50%;
justify-content: center;
align-items: center;
transition: color 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
display: flex;
position: fixed;
bottom: 95px;
right: 30px;
transform: scale(1);
box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);

}

#scrollUp:hover {
opacity: 1;
transform: scale(1.1);
}

#scrollUp svg use {
fill: #000;
height: 20px;
width: 20px;
}

#scrollUp:hover svg {
fill: #f8d24e;
}
35 changes: 35 additions & 0 deletions src/style/scss/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:opsz,[email protected],400;9..40,500;9..40,700&display=swap");
* {
box-sizing: border-box;
scroll-behavior: smooth;
}

html,
Expand Down Expand Up @@ -362,4 +363,38 @@ body {
[data-content=category] .books__book {
flex-basis: calc(20% - 25px);
}
}
#scrollUp {
z-index: 1000;
cursor: pointer;
width: 50px;
height: 50px;
opacity: 0.7;
fill: #000;
background-color: #fcfcfc;
border: none;
border-radius: 50%;
justify-content: center;
align-items: center;
transition: color 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
display: flex;
position: fixed;
bottom: 95px;
right: 30px;
transform: scale(1);
box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
}

#scrollUp:hover {
opacity: 1.1;
background-color: rgba(252, 252, 252, 0.5490196078);
cursor: pointer;
}

#top-btn svg {
fill: #000;
}

#top-btn:hover svg {
fill: #f8d24e;
}/*# sourceMappingURL=main.css.map */
2 changes: 1 addition & 1 deletion src/style/scss/main.css.map

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

1 change: 1 addition & 0 deletions src/style/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
@import './home';
@import './category-list';
@import './books';
@import './scrollUp';

0 comments on commit a59c468

Please sign in to comment.