{"id":6448,"date":"2024-01-11T16:40:00","date_gmt":"2024-01-11T16:40:00","guid":{"rendered":"https:\/\/codehim.com\/?p=6448"},"modified":"2024-01-22T14:44:04","modified_gmt":"2024-01-22T09:44:04","slug":"smooth-scroll-in-vanilla-js","status":"publish","type":"post","link":"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/","title":{"rendered":"Smooth Scroll in Vanilla JS"},"content":{"rendered":"<p>This Vanilla JS code snippet helps you to create a smooth scroll to sections. It comes with a smooth scrolling list in which list items can be clicked and it will smoothly scroll up. You can integrate this code snippet to make a smooth scrolling list.<\/p>\n<h2>How to Create Smooth Scroll in Vanilla JS<\/h2>\n<p>1. First of all, create the HTML structure as follows:<\/p>\n<pre class=\"prettyprint linenums lang-html\"> &lt;ul&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n  &lt;li&gt;CLICK TO SCROLL HERE&lt;\/li&gt;\r\n&lt;\/ul&gt;<\/pre>\n<p>2. After that, add the following CSS styles to your project:<\/p>\n<pre class=\"prettyprint linenums lang-css\">* {\r\n  margin: 0;\r\n  padding: 0;\r\n  -webkit-font-smoothing: antialiased;\r\n  -moz-osx-font-smoothing: grayscale;\r\n  -webkit-overflow-scrolling: touch;\r\n  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\r\n  -moz-tap-highlight-color: rgba(0, 0, 0, 0);\r\n  tap-highlight-color: rgba(0, 0, 0, 0);\r\n}\r\n\r\nul li:nth-child(1) {\r\n  color: rgba(60, 60, 80, 0.8);\r\n  background: rgba(0, 0, 255, 0.0333333333);\r\n}\r\n\r\nul li:nth-child(2) {\r\n  color: rgba(120, 120, 160, 0.8);\r\n  background: rgba(0, 0, 255, 0.0666666667);\r\n}\r\n\r\nul li:nth-child(3) {\r\n  color: rgba(180, 180, 240, 0.8);\r\n  background: rgba(0, 0, 255, 0.1);\r\n}\r\n\r\nul li:nth-child(4) {\r\n  color: rgba(240, 240, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.1333333333);\r\n}\r\n\r\nul li:nth-child(5) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.1666666667);\r\n}\r\n\r\nul li:nth-child(6) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.2);\r\n}\r\n\r\nul li:nth-child(7) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.2333333333);\r\n}\r\n\r\nul li:nth-child(8) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.2666666667);\r\n}\r\n\r\nul li:nth-child(9) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.3);\r\n}\r\n\r\nul li:nth-child(10) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.3333333333);\r\n}\r\n\r\nul li:nth-child(11) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.3666666667);\r\n}\r\n\r\nul li:nth-child(12) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.4);\r\n}\r\n\r\nul li:nth-child(13) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.4333333333);\r\n}\r\n\r\nul li:nth-child(14) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.4666666667);\r\n}\r\n\r\nul li:nth-child(15) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.5);\r\n}\r\n\r\nul li:nth-child(16) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.5333333333);\r\n}\r\n\r\nul li:nth-child(17) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.5666666667);\r\n}\r\n\r\nul li:nth-child(18) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.6);\r\n}\r\n\r\nul li:nth-child(19) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.6333333333);\r\n}\r\n\r\nul li:nth-child(20) {\r\n  color: rgba(255, 255, 255, 0.8);\r\n  background: rgba(0, 0, 255, 0.6666666667);\r\n}\r\n\r\nul {\r\n  position: relative;\r\n  top: 0;\r\n  right: 0;\r\n  bottom: 0;\r\n  left: 0;\r\n  width: 90%;\r\n  max-width: 300px;\r\n  height: 640px;\r\n  overflow: auto;\r\n  margin: auto;\r\n  border-radius: 4px;\r\n  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);\r\n}\r\nul li {\r\n  width: 100%;\r\n  height: 80px;\r\n  font: 300 12px\/80px Arial, sans-serif;\r\n  color: rgba(255, 255, 255, 0.5);\r\n  text-align: center;\r\n  list-style: none;\r\n  cursor: pointer;\r\n}\r\nul li.is-selected {\r\n  background: #fbfbfb;\r\n  color: rgba(0, 0, 255, 0.5);\r\n}<\/pre>\n<p>3. Finally, add the following JavaScript code and done.<\/p>\n<pre class=\"prettyprint linenums lang-js\">document.\r\nquerySelector('ul').\r\naddEventListener('click', function (e) {\r\n  smoothScrollTo(selected(e.target, this).offsetTop, this);\r\n});\r\n\r\nfunction smoothScrollTo(destination, parent, time) {\r\n  let scroll = init();\r\n  requestAnimationFrame(shouldScroll);\r\n\r\n  function init() {\r\n    let start = parent.scrollTop;\r\n    let ticks = time || 30;\r\n    let i = 0;\r\n    let positionY = () =&gt; (destination - start) * i \/ ticks + start;\r\n    let isFinished = () =&gt; i++ &gt;= ticks;\r\n    return { positionY, isFinished };\r\n  }\r\n\r\n  function shouldScroll() {\r\n    if (scroll.isFinished()) return;\r\n    parent.scrollTop = scroll.positionY();\r\n    requestAnimationFrame(shouldScroll);\r\n  }\r\n}\r\n\r\nfunction selected(elem, parent) {\r\n  for (let i = 0; i &lt; parent.children.length; i++) {\r\n    parent.children[i].classList.remove('is-selected');\r\n  }\r\n  elem.classList.add('is-selected');\r\n  return elem;\r\n}<\/pre>\n<p>That&#8217;s all! hopefully, you have successfully integrated this smooth scroll code snippet into your project. If you have any questions or facing any issues, feel free to comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This Vanilla JS code snippet helps you to create a smooth scroll to sections. It comes with a smooth scrolling&#8230;<\/p>\n","protected":false},"author":1,"featured_media":6464,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[116],"tags":[78],"class_list":["post-6448","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vanilla-javascript","tag-scrolling"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Smooth Scroll in Vanilla JS &#8212; CodeHim<\/title>\n<meta name=\"description\" content=\"Here is a lightweight Vanilla JS code snippet to create smooth scroll functionality. 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\/smooth-scroll-in-vanilla-js\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Smooth Scroll in Vanilla JS &#8212; CodeHim\" \/>\n<meta property=\"og:description\" content=\"Here is a lightweight Vanilla JS code snippet to create smooth scroll functionality. You can view demo and download code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/\" \/>\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-11T16:40:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-22T09:44:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/05\/www.codehim-3.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\/smooth-scroll-in-vanilla-js\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/\"},\"author\":{\"name\":\"Asif Mughal\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed\"},\"headline\":\"Smooth Scroll in Vanilla JS\",\"datePublished\":\"2024-01-11T16:40:00+00:00\",\"dateModified\":\"2024-01-22T09:44:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/\"},\"wordCount\":116,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/codehim.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/05\/www.codehim-3.png\",\"keywords\":[\"Scrolling Effects\"],\"articleSection\":[\"Vanilla JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/\",\"url\":\"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/\",\"name\":\"Smooth Scroll in Vanilla JS &#8212; CodeHim\",\"isPartOf\":{\"@id\":\"https:\/\/codehim.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/05\/www.codehim-3.png\",\"datePublished\":\"2024-01-11T16:40:00+00:00\",\"dateModified\":\"2024-01-22T09:44:04+00:00\",\"description\":\"Here is a lightweight Vanilla JS code snippet to create smooth scroll functionality. You can view demo and download code.\",\"breadcrumb\":{\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/#primaryimage\",\"url\":\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/05\/www.codehim-3.png\",\"contentUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2022\/05\/www.codehim-3.png\",\"width\":1280,\"height\":960,\"caption\":\"Smooth Scroll in Vanilla JS\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/#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\":\"Smooth Scroll in Vanilla JS\"}]},{\"@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":"Smooth Scroll in Vanilla JS &#8212; CodeHim","description":"Here is a lightweight Vanilla JS code snippet to create smooth scroll functionality. 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\/smooth-scroll-in-vanilla-js\/","og_locale":"en_US","og_type":"article","og_title":"Smooth Scroll in Vanilla JS &#8212; CodeHim","og_description":"Here is a lightweight Vanilla JS code snippet to create smooth scroll functionality. You can view demo and download code.","og_url":"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/","og_site_name":"CodeHim","article_publisher":"https:\/\/www.facebook.com\/codehimofficial","article_published_time":"2024-01-11T16:40:00+00:00","article_modified_time":"2024-01-22T09:44:04+00:00","og_image":[{"width":1280,"height":960,"url":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/05\/www.codehim-3.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\/smooth-scroll-in-vanilla-js\/#article","isPartOf":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/"},"author":{"name":"Asif Mughal","@id":"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed"},"headline":"Smooth Scroll in Vanilla JS","datePublished":"2024-01-11T16:40:00+00:00","dateModified":"2024-01-22T09:44:04+00:00","mainEntityOfPage":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/"},"wordCount":116,"commentCount":0,"publisher":{"@id":"https:\/\/codehim.com\/#organization"},"image":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/#primaryimage"},"thumbnailUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/05\/www.codehim-3.png","keywords":["Scrolling Effects"],"articleSection":["Vanilla JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/","url":"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/","name":"Smooth Scroll in Vanilla JS &#8212; CodeHim","isPartOf":{"@id":"https:\/\/codehim.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/#primaryimage"},"image":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/#primaryimage"},"thumbnailUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/05\/www.codehim-3.png","datePublished":"2024-01-11T16:40:00+00:00","dateModified":"2024-01-22T09:44:04+00:00","description":"Here is a lightweight Vanilla JS code snippet to create smooth scroll functionality. You can view demo and download code.","breadcrumb":{"@id":"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/#primaryimage","url":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/05\/www.codehim-3.png","contentUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2022\/05\/www.codehim-3.png","width":1280,"height":960,"caption":"Smooth Scroll in Vanilla JS"},{"@type":"BreadcrumbList","@id":"https:\/\/codehim.com\/vanilla-javascript\/smooth-scroll-in-vanilla-js\/#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":"Smooth Scroll in Vanilla JS"}]},{"@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":6258,"_links":{"self":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts\/6448","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=6448"}],"version-history":[{"count":0,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts\/6448\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/media\/6464"}],"wp:attachment":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/media?parent=6448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/categories?post=6448"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/tags?post=6448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}