Day #17 of Learning in Public

Day #17 of Learning in Public

In today's project, I unveiled "Marvel Assemble," a dynamic carousel webpage born from HTML, CSS, and JavaScript synergy. Leveraging key codes and the keydown functionality, I crafted a seamless navigation experience. Users can effortlessly slide through a captivating array of Marvel heroes. HTML laid the foundation, CSS added style finesse, and JavaScript brought interactive life. The fusion resulted in an engaging digital showcase. This venture not only showcases technical prowess but also signifies the ongoing evolution of my web development skills. Eager to refine "Marvel Assemble" and explore more innovative features in the days ahead. ??♂????.

For left arrow keycode is 37.

For right arrow keycode is 39.

const slider = document.querySelector(".slider");
function flow(e) {
 const img = document.querySelectorAll(".img");

 if (e.keyCode === 37 || e.keyCode === 39) {
  if (e.keyCode == 37) {
   // If left arrow, move the last image to the beginning
   slider.prepend(img[img.length - 1]);
  } else if (e.keyCode == 39) {
   // If right arrow, move the first image to the end
   slider.append(img[0]);
  }
 }

 // Check if the click event happened on the next or prev elements
 if (e.target.matches(".next")) {
  slider.append(img[0]);
 } else if (e.target.matches(".prev")) {
  slider.prepend(img[img.length - 1]);
 }
}

document.addEventListener("click", flow, false);
document.addEventListener("keydown", flow, false);
        

要查看或添加评论,请登录

Pratik Kumar Jaiswal的更多文章

  • Day 25 Learning In Public

    Day 25 Learning In Public

    Day 25: Explored the power of React Query and utilized Tanstack to optimize data fetching and state management in React…

    1 条评论
  • Day 23 :Learning In Public

    Day 23 :Learning In Public

    "Unlocking React's Potential: A Deep Dive into the Callback Hook" Mastered the Callback Hook in React today, a powerful…

    1 条评论
  • DAY #16 of Learning In Public

    DAY #16 of Learning In Public

    Today's creative Endeavor resulted in : A tranquil meditation page crafted with HTML, CSS, and JavaScript. The soothing…

  • DAY #14 OF LEARNING IN PUBLIC

    DAY #14 OF LEARNING IN PUBLIC

    Affordigo Day 14: Explored the CSS property, a pivotal tool in creating versatile, multi-line layouts within flex…

  • Day #13 of Learning In Public

    Day #13 of Learning In Public

    Day 13: Today's exploration led me to the intriguing realm of the CSS property. Discovering how to modify and animate…

    2 条评论
  • Day 12: Today, I delved into the fundamentals of setting up a project.

    Day 12: Today, I delved into the fundamentals of setting up a project.

    Learning the essentials of project structuring, media queries, and responsive design principles has been pivotal. It's…

    2 条评论
  • Save your preloader spinner

    Save your preloader spinner

    codepen link provided below Loader Spinner Follow me Pratik Kumar Jaiswal for more!!! ?? ??#html #css #javascript…

  • Day #10 of Learning In Public

    Day #10 of Learning In Public

    Day 10: Diving into the world of Sass, I harnessed the versatility of , , and properties to create dynamic layouts…

  • Day #9 of Learning in Public.

    Day #9 of Learning in Public.

    A productive day exploring the power of in CSS for layering elements and mastering linear hover effects. These skills…

    1 条评论
  • Day #8 of Learning in Public

    Day #8 of Learning in Public

    Today I learned how to add form and do custom animations as per your choice. Used focus and placeholders in #sass.