Submitted almost 3 years ago
Ecommerce Sneaker Landing Page with Html, Sass, Vanilla Js,
@basemosman2
Design comparison
SolutionDesign
Solution retrospective
I am testing my knowledge of vanilla JS, for that reason I forced myself not to use any framework for this challenge. I would like to receive feedback on things that can be improved. Thanks in advance.
best wishes
Community feedback
- @renrasPosted almost 3 years ago
few things I think it can improve on:
- your modal's height is not responsive to vh, I think position:fixed is better instead of absolute and top,left,right,bottom:0 will do the job instead of setting a height and width
let selectedThumbnail = selectedImg.slice(0,selectedImg.indexOf('.jpg'))+'-thumbnail.jpg';
I believe what you are trying to achieve here can be done using string.replace instead and is faster than slice.
function activethumbnailImg(thumbnailImgs,mainProductImg){ thumbnailImgs.forEach((img)=>{ img.addEventListener('click',(e)=>{ thumbnailImgs.forEach((img)=>{ img.parentElement.classList.remove('active'); }); let imgName = `images/image-${e.target.dataset.name}.jpg`; mainProductImg.setAttribute('src',imgName); e.target.parentElement.classList.add('active'); }); }); }
you are nesting a foreach inside a foreach which runs kinda slow. I believe this can still be optimized using event delegation instead and traversing
Marked as helpful1@basemosman2Posted almost 3 years ago@renras thanks for your feedback appreciated it.
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord