Skip to content

Commit

Permalink
Merge pull request #3 from pavel-alpinweb/module1-task3
Browse files Browse the repository at this point in the history
  • Loading branch information
keksobot authored Oct 24, 2024
2 parents eb160ea + a7edfe6 commit cf47d32
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
2 changes: 2 additions & 0 deletions source/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ <h2 class="slider__item-title">История</h2>
</div>
<div class="slider__pagination swiper-pagination"></div>
</div>

<div class="screen__blocker" id="history-screen-blocker"></div>
</section>

<section class="screen screen--hidden screen--prizes" id="prizes">
Expand Down
2 changes: 2 additions & 0 deletions source/js/modules/animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export default () => {
document.body.classList.add(`document-ready`);
});
};

export const SCREEN_BLOCKER_TIMEOUT = 400;
19 changes: 18 additions & 1 deletion source/js/modules/full-page-scroll.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import throttle from 'lodash/throttle';
import {SCREEN_BLOCKER_TIMEOUT} from "./animations";

export default class FullPageScroll {
constructor() {
this.THROTTLE_TIMEOUT = 1000;
this.scrollFlag = true;
this.timeout = null;
this.scrollBlockerTimeout = 0;

this.screenElements = document.querySelectorAll(`.screen:not(.screen--result)`);
this.menuElements = document.querySelectorAll(`.page-header__menu .js-menu-link`);
Expand Down Expand Up @@ -46,7 +48,12 @@ export default class FullPageScroll {
}

changePageDisplay() {
this.changeVisibilityDisplay();
const activeScreen = this.screenElements[this.activeScreen];
this.scrollBlockerTimeout = activeScreen.classList.contains(`screen--prizes`) ? SCREEN_BLOCKER_TIMEOUT : 0;
this.showScreenBlocker();
setTimeout(() => {
this.changeVisibilityDisplay();
}, this.scrollBlockerTimeout);
this.changeActiveMenuItem();
this.emitChangeDisplayEvent();
}
Expand All @@ -62,6 +69,16 @@ export default class FullPageScroll {
}, 100);
}

showScreenBlocker() {
const activeScreen = this.screenElements[this.activeScreen];
const screenBlocker = document.querySelector(`#history-screen-blocker`);
if (activeScreen.classList.contains(`screen--prizes`)) {
screenBlocker.classList.add(`show`);
} else {
screenBlocker.classList.remove(`show`);
}
}

changeActiveMenuItem() {
const activeItem = Array.from(this.menuElements).find((item) => item.dataset.href === this.screenElements[this.activeScreen].id);
if (activeItem) {
Expand Down
28 changes: 22 additions & 6 deletions source/scss/blocks/screen.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
@media (max-width: $tablet - 1) and (orientation: landscape) {
height: 100vh;
}

&.active {
.screen__footer {
bottom: 0;
}
}
}

.screen__wrapper {
Expand All @@ -30,6 +36,22 @@
z-index: 1;
}

.screen__blocker {
width: 100%;
height: 0;
position: absolute;
background-color: $c-dark;
right: 0;
left: 0;
bottom: 0;
z-index: 1;
transition: height 0.4s cubic-bezier(0.17,1,0.8,0.98);

&.show {
height: 100%;
}
}

.screen__disclaimer {
position: absolute;
bottom: 0;
Expand Down Expand Up @@ -355,9 +377,3 @@
.screen--rules {
background-color: $c-dark;
}

.document-ready {
.screen__footer {
bottom: 0;
}
}

0 comments on commit cf47d32

Please sign in to comment.