{"id":7219,"date":"2024-01-11T17:48:00","date_gmt":"2024-01-11T17:48:00","guid":{"rendered":"https:\/\/codehim.com\/?p=7219"},"modified":"2024-01-22T15:50:05","modified_gmt":"2024-01-22T10:50:05","slug":"before-after-image-slider-in-vanilla-javascript","status":"publish","type":"post","link":"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/","title":{"rendered":"Before After Image Slider in Vanilla JavaScript"},"content":{"rendered":"<p>This Vanilla JavaScript code snippet helps you to create before and after image comparison slider. It comes with scrolling and touch support to slide the vertical slider over the image to see the before and after difference.<\/p>\n<h2>How to Create Before After Image Slider in Vanilla JavaScript<\/h2>\n<p>1. First of all, load the Font Awesome CSS into the head tag of your HTML page.<\/p>\n<pre class=\"prettyprint linenums lang-html\">&lt;link rel='stylesheet' href='https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/font-awesome\/4.7.0\/css\/font-awesome.css'&gt;\r\n<\/pre>\n<p>2. After that, create a div element with a class name &#8220;before&#8221; and place your first image inside it. Similarly, create another div element with a class name &#8220;after&#8221; and place your second image inside it.<\/p>\n<p>Create a div with a class name &#8220;scroller&#8221; and place a SVG icon ij it for the vertical slider. Wrap all these elements into a div element and define its class name &#8220;wrapper&#8221;. So, the complete HTML structure of the image comparison slider is as follows:<\/p>\n<pre class=\"prettyprint linenums lang-html\">&lt;div id=\"page\"&gt;\r\n&lt;div class=\"wrapper\"&gt;\r\n  &lt;div class=\"before\"&gt;\r\n    &lt;img class=\"content-image\" src=\"https:\/\/farm2.staticflickr.com\/1638\/26145024230_06acd55d1b_b.jpg\" draggable=\"false\"\/&gt;   &lt;\/div&gt;\r\n  &lt;div class=\"after\"&gt;\r\n    &lt;img class=\"content-image\" src=\"https:\/\/farm2.staticflickr.com\/1663\/25814974803_d4c55ff708_b.jpg\" draggable=\"false\"\/&gt;\r\n  &lt;\/div&gt;\r\n  &lt;div class=\"scroller\"&gt;\r\n    &lt;svg class=\"scroller__thumb\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100\" height=\"100\" viewBox=\"0 0 100 100\"&gt;&lt;polygon points=\"0 50 37 68 37 32 0 50\" style=\"fill:#fff\"\/&gt;&lt;polygon points=\"100 50 64 32 64 68 100 50\" style=\"fill:#fff\"\/&gt;&lt;\/svg&gt;\r\n  &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>3. Style the image comparison slider using the following CSS. You can set the custom values for the image size according to your needs.<\/p>\n<pre class=\"prettyprint linenums lang-css\">\/* Our normalize css *\/\r\n*{\r\n  margin:0;\r\n  box-sizing: border-box;\r\n}\r\n\r\n\/* Our wrapper *\/\r\n.wrapper{\r\n  width: 900px;\r\n  height: 600px;\r\n  position: relative;\r\n\r\n  overflow:hidden;\r\n  box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);\r\n}\r\n\r\n\/* Our image information *\/\r\n.before,\r\n.after {\r\n  width:100%;\r\n  height:100%;\r\n  background-repeat:no-repeat;\r\n  background-color: white;\r\n  background-size: cover;\r\n  background-position: center;\r\n  position: absolute;\r\n  top:0;\r\n  left:0;\r\n  pointer-events:none;\r\n  overflow: hidden;\r\n}\r\n\r\n.content-image{\r\n  height:100%;\r\n}\r\n\r\n.after{\r\n  width:125px;\r\n}\r\n\r\n.scroller{\r\n  width: 50px;\r\n  height:50px;\r\n  position: absolute;\r\n  left:100px;\r\n  top:50%;\r\n  transform:translateY(-50%);\r\n  border-radius:50%;\r\n  background-color: transparent;\r\n  opacity:0.9;\r\n  pointer-events:auto;\r\n  cursor: pointer;\r\n}\r\n\r\n.scroller:hover{\r\n  opacity:1;\r\n}\r\n\r\n.scrolling{\r\n  pointer-events:none;\r\n  opacity:1;\r\n  \/\/ z-index: 1;\r\n}\r\n\r\n.scroller__thumb{\r\n  width:100%;\r\n  height:100%;\r\n  padding:5px;\r\n}\r\n\r\n.scroller:before,\r\n.scroller:after{\r\n  content:\" \";\r\n  display: block;\r\n  width: 7px;\r\n  height: 9999px;\r\n  position: absolute;\r\n  left: 50%;\r\n  margin-left: -3.5px;\r\n  z-index: 30;\r\n  transition:0.1s;\r\n}\r\n.scroller:before{\r\n  top:100%;\r\n}\r\n.scroller:after{\r\n  bottom:100%;\r\n}\r\n\r\n\/* If you want to cahnge the colors, make sure you change the fill in the svgs to match *\/\r\n.scroller{\r\n  border: 5px solid #fff;\r\n}\r\n.scroller:before,\r\n.scroller:after{\r\n  background: #fff;\r\n}<\/pre>\n<p>4. In the final step, add the following JavaScript function for before and after image comparison slider:<\/p>\n<pre class=\"prettyprint linenums lang-js\">\/\/ I hope this over-commenting helps. Let's do this!\r\n\/\/ Let's use the 'active' variable to let us know when we're using it\r\nlet active = false;\r\n\r\n\/\/ First we'll have to set up our event listeners\r\n\/\/ We want to watch for clicks on our scroller\r\ndocument.querySelector('.scroller').addEventListener('mousedown',function(){\r\n  active = true;\r\n  \/\/ Add our scrolling class so the scroller has full opacity while active\r\n  document.querySelector('.scroller').classList.add('scrolling');\r\n});\r\n\/\/ We also want to watch the body for changes to the state,\r\n\/\/ like moving around and releasing the click\r\n\/\/ so let's set up our event listeners\r\ndocument.body.addEventListener('mouseup',function(){\r\n  active = false;\r\n  document.querySelector('.scroller').classList.remove('scrolling');\r\n});\r\ndocument.body.addEventListener('mouseleave',function(){\r\n  active = false;\r\n  document.querySelector('.scroller').classList.remove('scrolling');\r\n});\r\n\r\n\/\/ Let's figure out where their mouse is at\r\ndocument.body.addEventListener('mousemove',function(e){\r\n  if (!active) return;\r\n  \/\/ Their mouse is here...\r\n  let x = e.pageX;\r\n  \/\/ but we want it relative to our wrapper\r\n  x -= document.querySelector('.wrapper').getBoundingClientRect().left;\r\n  \/\/ Okay let's change our state\r\n  scrollIt(x);\r\n});\r\n\r\n\/\/ Let's use this function\r\nfunction scrollIt(x){\r\n    let transform = Math.max(0,(Math.min(x,document.querySelector('.wrapper').offsetWidth)));\r\n    document.querySelector('.after').style.width = transform+\"px\";\r\n    document.querySelector('.scroller').style.left = transform-25+\"px\";\r\n}\r\n\r\n\/\/ Let's set our opening state based off the width, \r\n\/\/ we want to show a bit of both images so the user can see what's going on\r\nscrollIt(150);\r\n\r\n\/\/ And finally let's repeat the process for touch events\r\n\/\/ first our middle scroller...\r\ndocument.querySelector('.scroller').addEventListener('touchstart',function(){\r\n  active = true;\r\n  document.querySelector('.scroller').classList.add('scrolling');\r\n});\r\ndocument.body.addEventListener('touchend',function(){\r\n  active = false;\r\n  document.querySelector('.scroller').classList.remove('scrolling');\r\n});\r\ndocument.body.addEventListener('touchcancel',function(){\r\n  active = false;\r\n  document.querySelector('.scroller').classList.remove('scrolling');\r\n});<\/pre>\n<p>That&#8217;s all! hopefully, you have successfully created a before after image slider using Vanilla JavaScript. If you have any questions or suggestions, feel free to comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This Vanilla JavaScript code snippet helps you to create before and after image comparison slider. It comes with scrolling and&#8230;<\/p>\n","protected":false},"author":1,"featured_media":7276,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[116],"tags":[],"class_list":["post-7219","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vanilla-javascript"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Before After Image Slider in Vanilla JavaScript &#8212; CodeHim<\/title>\n<meta name=\"description\" content=\"Here is free Vanilla JavaScript code snippet to create before and after image comparison slider. You can view demo and download code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Before After Image Slider in Vanilla JavaScript &#8212; CodeHim\" \/>\n<meta property=\"og:description\" content=\"Here is free Vanilla JavaScript code snippet to create before and after image comparison slider. You can view demo and download code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"CodeHim\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codehimofficial\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-11T17:48:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-22T10:50:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/09\/before-after-image-slider-in-vanilla-javascript.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"960\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Asif Mughal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@CodeHimOfficial\" \/>\n<meta name=\"twitter:site\" content=\"@CodeHimOfficial\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Asif Mughal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/\"},\"author\":{\"name\":\"Asif Mughal\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed\"},\"headline\":\"Before After Image Slider in Vanilla JavaScript\",\"datePublished\":\"2024-01-11T17:48:00+00:00\",\"dateModified\":\"2024-01-22T10:50:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/\"},\"wordCount\":218,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/codehim.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/09\/before-after-image-slider-in-vanilla-javascript.png\",\"articleSection\":[\"Vanilla JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/\",\"url\":\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/\",\"name\":\"Before After Image Slider in Vanilla JavaScript &#8212; CodeHim\",\"isPartOf\":{\"@id\":\"https:\/\/codehim.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/09\/before-after-image-slider-in-vanilla-javascript.png\",\"datePublished\":\"2024-01-11T17:48:00+00:00\",\"dateModified\":\"2024-01-22T10:50:05+00:00\",\"description\":\"Here is free Vanilla JavaScript code snippet to create before and after image comparison slider. You can view demo and download code.\",\"breadcrumb\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#primaryimage\",\"url\":\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/09\/before-after-image-slider-in-vanilla-javascript.png\",\"contentUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/09\/before-after-image-slider-in-vanilla-javascript.png\",\"width\":1280,\"height\":960,\"caption\":\"Before After Image Slider in Vanilla JavaScript\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/codehim.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Vanilla JavaScript\",\"item\":\"https:\/\/codehim.com\/category\/vanilla-javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Before After Image Slider in Vanilla JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/codehim.com\/#website\",\"url\":\"https:\/\/codehim.com\/\",\"name\":\"CodeHim\",\"description\":\"Web Design Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/codehim.com\/#organization\"},\"alternateName\":\"Web Design Codes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/codehim.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/codehim.com\/#organization\",\"name\":\"CodeHim - Web Design Code & Scripts\",\"url\":\"https:\/\/codehim.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg\",\"contentUrl\":\"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg\",\"width\":280,\"height\":280,\"caption\":\"CodeHim - Web Design Code & Scripts\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/codehimofficial\",\"https:\/\/x.com\/CodeHimOfficial\",\"https:\/\/www.instagram.com\/codehim\/\",\"https:\/\/www.linkedin.com\/company\/codehim\",\"https:\/\/co.pinterest.com\/codehim\/\",\"https:\/\/www.youtube.com\/@codehim\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed\",\"name\":\"Asif Mughal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g\",\"caption\":\"Asif Mughal\"},\"description\":\"I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences. I truly enjoy what I'm doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.\",\"sameAs\":[\"https:\/\/codehim.com\"],\"url\":\"https:\/\/codehim.com\/author\/asif-mughal\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Before After Image Slider in Vanilla JavaScript &#8212; CodeHim","description":"Here is free Vanilla JavaScript code snippet to create before and after image comparison slider. You can view demo and download code.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Before After Image Slider in Vanilla JavaScript &#8212; CodeHim","og_description":"Here is free Vanilla JavaScript code snippet to create before and after image comparison slider. You can view demo and download code.","og_url":"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/","og_site_name":"CodeHim","article_publisher":"https:\/\/www.facebook.com\/codehimofficial","article_published_time":"2024-01-11T17:48:00+00:00","article_modified_time":"2024-01-22T10:50:05+00:00","og_image":[{"width":1280,"height":960,"url":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/09\/before-after-image-slider-in-vanilla-javascript.png","type":"image\/png"}],"author":"Asif Mughal","twitter_card":"summary_large_image","twitter_creator":"@CodeHimOfficial","twitter_site":"@CodeHimOfficial","twitter_misc":{"Written by":"Asif Mughal","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#article","isPartOf":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/"},"author":{"name":"Asif Mughal","@id":"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed"},"headline":"Before After Image Slider in Vanilla JavaScript","datePublished":"2024-01-11T17:48:00+00:00","dateModified":"2024-01-22T10:50:05+00:00","mainEntityOfPage":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/"},"wordCount":218,"commentCount":0,"publisher":{"@id":"https:\/\/codehim.com\/#organization"},"image":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/09\/before-after-image-slider-in-vanilla-javascript.png","articleSection":["Vanilla JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/","url":"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/","name":"Before After Image Slider in Vanilla JavaScript &#8212; CodeHim","isPartOf":{"@id":"https:\/\/codehim.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#primaryimage"},"image":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/09\/before-after-image-slider-in-vanilla-javascript.png","datePublished":"2024-01-11T17:48:00+00:00","dateModified":"2024-01-22T10:50:05+00:00","description":"Here is free Vanilla JavaScript code snippet to create before and after image comparison slider. You can view demo and download code.","breadcrumb":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#primaryimage","url":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/09\/before-after-image-slider-in-vanilla-javascript.png","contentUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/09\/before-after-image-slider-in-vanilla-javascript.png","width":1280,"height":960,"caption":"Before After Image Slider in Vanilla JavaScript"},{"@type":"BreadcrumbList","@id":"https:\/\/codehim.com\/vanilla-javascript\/before-after-image-slider-in-vanilla-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codehim.com\/"},{"@type":"ListItem","position":2,"name":"Vanilla JavaScript","item":"https:\/\/codehim.com\/category\/vanilla-javascript\/"},{"@type":"ListItem","position":3,"name":"Before After Image Slider in Vanilla JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/codehim.com\/#website","url":"https:\/\/codehim.com\/","name":"CodeHim","description":"Web Design Code Snippets","publisher":{"@id":"https:\/\/codehim.com\/#organization"},"alternateName":"Web Design Codes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codehim.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/codehim.com\/#organization","name":"CodeHim - Web Design Code & Scripts","url":"https:\/\/codehim.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/#\/schema\/logo\/image\/","url":"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg","contentUrl":"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg","width":280,"height":280,"caption":"CodeHim - Web Design Code & Scripts"},"image":{"@id":"https:\/\/codehim.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codehimofficial","https:\/\/x.com\/CodeHimOfficial","https:\/\/www.instagram.com\/codehim\/","https:\/\/www.linkedin.com\/company\/codehim","https:\/\/co.pinterest.com\/codehim\/","https:\/\/www.youtube.com\/@codehim"]},{"@type":"Person","@id":"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed","name":"Asif Mughal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g","caption":"Asif Mughal"},"description":"I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences. I truly enjoy what I'm doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.","sameAs":["https:\/\/codehim.com"],"url":"https:\/\/codehim.com\/author\/asif-mughal\/"}]}},"views":8764,"_links":{"self":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts\/7219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/comments?post=7219"}],"version-history":[{"count":0,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts\/7219\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/media\/7276"}],"wp:attachment":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/media?parent=7219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/categories?post=7219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/tags?post=7219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}