Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Модуль 5 #6

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion 5-module/1-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
function hideSelf() {
// ваш код...
const button = document.querySelector('.hide-self-button');
button.onclick = () => {
button.hidden = true;
};
}
12 changes: 11 additions & 1 deletion 5-module/2-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
function toggleText() {
// ваш код...
const button = document.querySelector('.toggle-text-button');
const div = document.getElementById('text');

button.onclick = () => {
if (div.hidden){
div.hidden = false;
} else {
div.hidden = true;
}
Comment on lines +6 to +10

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: так как hidden принимает boolean, этот if можно поменять на: div.hidden = !div.hidden

}

}
42 changes: 41 additions & 1 deletion 5-module/3-task/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
function initCarousel() {
// ваш код...
const buttonRight = document.querySelector('.carousel__arrow.carousel__arrow_right');
const buttonLeft = document.querySelector('.carousel__arrow.carousel__arrow_left');
const carouselInner = document.querySelector(".carousel__inner");
const carouselSlide = document.querySelectorAll('.carousel__slide');

buttonLeft.style.display = 'none';
let currentSlide = 0;
const totalSlide = 3;


function updateCarousel() {
const slideWidth = carouselSlide[0].offsetWidth;
carouselInner.style.transform = `translateX(-${currentSlide * slideWidth}px)`;
}

buttonRight.onclick = () => {
if (currentSlide < totalSlide) {
currentSlide++;
}
if (currentSlide == totalSlide) {
buttonRight.style.display = 'none';
} else {
buttonRight.style.display = '';
buttonLeft.style.display = '';
}
updateCarousel();
}

buttonLeft.onclick = () => {
if (currentSlide > 0) {
currentSlide--;
}
if (currentSlide == 0) {
buttonLeft.style.display = 'none';
} else {
buttonRight.style.display = '';
buttonLeft.style.display = '';
}
updateCarousel();
}
}