commit 31b27e06499083da0431b7642e09f4c74d163eec Author: Sergey Yarkov Date: Wed Oct 2 19:35:20 2019 +0300 final diff --git a/img/1.png b/img/1.png new file mode 100644 index 0000000..30daef7 Binary files /dev/null and b/img/1.png differ diff --git a/img/2.png b/img/2.png new file mode 100644 index 0000000..36e3385 Binary files /dev/null and b/img/2.png differ diff --git a/img/3.png b/img/3.png new file mode 100644 index 0000000..f23d75b Binary files /dev/null and b/img/3.png differ diff --git a/img/4.png b/img/4.png new file mode 100644 index 0000000..579746e Binary files /dev/null and b/img/4.png differ diff --git a/img/5.png b/img/5.png new file mode 100644 index 0000000..14faf74 Binary files /dev/null and b/img/5.png differ diff --git a/img/6.png b/img/6.png new file mode 100644 index 0000000..de630f2 Binary files /dev/null and b/img/6.png differ diff --git a/style.css b/style.css new file mode 100644 index 0000000..9e26bda --- /dev/null +++ b/style.css @@ -0,0 +1,37 @@ +.container { + width: 100%; +} + +section { + margin-bottom: 15px; + padding-bottom: 15px; + border-bottom: 1px dashed #444; +} + +.block { + width: 75px; + height: 75px; + margin: 25px; + border: 2px solid #333; +} + +.active { + background: orange; +} + +.hide { + display: none; +} + +.img-12-min { + width: 64px; +} + +.img-12-max { + width: 128px; border: 3px solid #fff; + +} + +.active-img { + border: 3px solid black; +} \ No newline at end of file diff --git a/unit_21.html b/unit_21.html new file mode 100644 index 0000000..bb58ce6 --- /dev/null +++ b/unit_21.html @@ -0,0 +1,42 @@ + + + + + + + + + + Unit 20 + + + +
+
+
+ # + # + # + # + # + # +
+
+ # +
+

Картинка 1

+ + + +
+
+
+ + + +
+ + + + + \ No newline at end of file diff --git a/unit_21.js b/unit_21.js new file mode 100644 index 0000000..5dfbf80 --- /dev/null +++ b/unit_21.js @@ -0,0 +1,81 @@ +function imgSlider() { + const a = ['1.png', '2.png', '3.png', '4.png', '5.png', '6.png'], + images = document.querySelectorAll('.img-12-min'), + dataText = []; + let currImg = '0'; + + + function pushDataText() { + images.forEach(img => { + let textAttr = img.getAttribute('data-text'); + dataText.push(textAttr); + }); + } + pushDataText(); + + function showMax() { + images.forEach((img, i) => { + img.addEventListener('click', () => { + images.forEach(img => img.classList.remove('active-img')); + + img.classList.add('active-img'); + currImg = i; + + // вывод активной картинки + document.querySelector('.div-12-max').innerHTML = `#`; + // вывод текста активной картинки + document.querySelector('.img-12-text').innerHTML = dataText[i]; + }); + }); + } + + function slidePrev() { + currImg = parseInt(currImg); + + if (currImg <= a.length && currImg >= 1) { + currImg--; + images.forEach(img => img.classList.remove('active-img')); + images[currImg].classList.add('active-img'); + + // вывод активной картинки + document.querySelector('.div-12-max').innerHTML = `#`; + // вывод текста активной картинки + document.querySelector('.img-12-text').innerHTML = dataText[currImg]; + } + } + + function slideNext() { + currImg = parseInt(currImg); + if (currImg <= a.length - 2) { + currImg++; + images.forEach(img => img.classList.remove('active-img')); + images[currImg].classList.add('active-img'); + + // вывод активной картинки + document.querySelector('.div-12-max').innerHTML = `#`; + // вывод текста активной картинки + document.querySelector('.img-12-text').innerHTML = dataText[currImg]; + } + } + + function resetSlider() { + currImg = parseInt(currImg); + + currImg = 0; + images.forEach(img => img.classList.remove('active-img')); + images[currImg].classList.add('active-img'); + + // вывод активной картинки + document.querySelector('.div-12-max').innerHTML = `#`; + // вывод текста активной картинки + document.querySelector('.img-12-text').innerHTML = dataText[currImg]; + } + + showMax(); + document.querySelector('.prev').onclick = slidePrev; + document.querySelector('.next').onclick = slideNext; + document.querySelector('.reset').onclick = resetSlider; +} +imgSlider(); + +