{"id":5483,"date":"2020-09-21T08:14:00","date_gmt":"2020-09-21T08:14:00","guid":{"rendered":"https:\/\/azoora.com\/blog\/?p=5483"},"modified":"2020-09-15T08:24:09","modified_gmt":"2020-09-15T08:24:09","slug":"onscroll-effect-toggle-css-classes-when-an-element-is-scrolled-into-view","status":"publish","type":"post","link":"https:\/\/azoora.com\/blog\/code\/onscroll-effect-toggle-css-classes-when-an-element-is-scrolled-into-view\/","title":{"rendered":"onscroll-effect: Toggle CSS Classes When An Element Is Scrolled Into View"},"content":{"rendered":"\n<p><strong>A tiny JavaScript library to enable&nbsp;<abbr title=\"Cascading Style Sheets\">CSS<\/abbr>&nbsp;animations when user scrolls.<\/strong><\/p>\n\n\n\n<p>This library toggles a class to an element when it appears on viewport when user scrolls. It lets you build CSS transitions or animations launched only when user scrolls on it. Only set a few HTML attributes, and code the rest with your CSS skills.<\/p>\n\n\n\n<p>Note that in order to not be JavaScript dependent, as default behavior, this library add the class when the element\u00a0<strong>is outside<\/strong>\u00a0of the viewport. This way, if you have any JavaScript issue, the default state of your element will appears on scroll.<\/p>\n\n\n\n<p>Sometimes, you may need the opposite behavior, i.e. adding a class when the element is inside the viewport. There is\u00a0<a href=\"https:\/\/twikito.github.io\/onscroll-effect\/#reverse\">an option for that<\/a>.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><strong>Demo<\/strong>: <a href=\"https:\/\/github.com\/Twikito\/onscroll-effect\/archive\/master.zip\">Link<\/a><\/p><p><strong>Download<\/strong>: <a href=\"https:\/\/github.com\/Twikito\/onscroll-effect\/archive\/master.zip\">Link<\/a><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>A tiny JavaScript library to enable&nbsp;CSS&nbsp;animations when user scrolls. This library toggles a class to an element when it appears on viewport when user scrolls. It lets you build CSS transitions or animations launched only when user scrolls on it. Only set a few HTML attributes, and code the rest with your CSS skills. Note [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":5484,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[4,145,12],"tags":[25,146,87],"jetpack_featured_media_url":"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/09\/onscroll-effect.gif","jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p7FQPL-1qr","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts\/5483"}],"collection":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/comments?post=5483"}],"version-history":[{"count":1,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts\/5483\/revisions"}],"predecessor-version":[{"id":5485,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts\/5483\/revisions\/5485"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/media\/5484"}],"wp:attachment":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/media?parent=5483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/categories?post=5483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/tags?post=5483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}