Added initial version.
This commit is contained in:
parent
4e81e20470
commit
8cfe4a8693
4 changed files with 178 additions and 0 deletions
17
js/002-swap-pictures.js
Normal file
17
js/002-swap-pictures.js
Normal 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);
|
||||
}
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue