Added initial version.

This commit is contained in:
Lewin Probst 2019-08-02 13:56:37 +02:00
parent 4e81e20470
commit 8cfe4a8693
4 changed files with 178 additions and 0 deletions

17
js/002-swap-pictures.js Normal file
View file

@ -0,0 +1,17 @@
function swapPicture() {
let bigImage = self.querySelector('.big-image picture');
// insert the big image before the one clicked on
this.parentNode.insertBefore(bigImage, this);
// move the clicked image to the big image container
self.querySelector('.big-image').appendChild(this);
// swap event listeners
this.removeEventListener('click', swapPicture);
bigImage.addEventListener('click', swapPicture);
}
self.querySelectorAll('.gallery-images picture')
.forEach((item, index) => {
item.addEventListener('click', swapPicture);
}
);