{"id":5866,"date":"2024-04-14T12:31:43","date_gmt":"2024-04-14T04:31:43","guid":{"rendered":"https:\/\/webflow.tenten.co\/?p=5866"},"modified":"2024-04-14T12:31:43","modified_gmt":"2024-04-14T04:31:43","slug":"bring-an-element-to-life-upon-entering-the-viewport","status":"publish","type":"post","link":"https:\/\/webflow.tenten.co\/en\/bring-an-element-to-life-upon-entering-the-viewport\/","title":{"rendered":"Bring an element to life upon entering the viewport"},"content":{"rendered":"\n<div class=\"docs_rich-text w-richtext\">\n<p>As a part of our series discussing After Effects and Lottie in Webflow, we developed a small cardboard box that was animated using After Effects. In this guide, we are going to configure the box to animate on the web by opening it upon scrolling into view and closing it upon scrolling out of view.<\/p>\n<p>We will accomplish this in three simple steps:<\/p>\n<ol>\n<li>Include the animation<\/li>\n<li>Establish the trigger<\/li>\n<li>Configure the animation<\/li>\n<\/ol>\n<h2>Include the animation<\/h2>\n<p>You will have to export your Lottie animation from After Effects and import it into your Webflow project. We exported the box using Bodymovin. Follow steps 3 and 4 of our comprehensive tutorial for a full walkthrough on how to do this.\u00a0<\/p>\n<p>For this particular project, you will need to create two sections \u2014 refer to our Section tutorial or <a href=\"https:\/\/webflow.com\/website\/After-Effects-and-Lottie-or-Animate-when-in-view\">duplicate the project<\/a>.<\/p>\n<p>To locate and insert the animation, utilize the image icon in the Assets panel located in the left toolbar and drag the box onto the Canvas between the two sections.\u00a0<\/p>\n<figure class=\"w-richtext-figure-type-image w-richtext-align-center\" data-rt-type=\"image\" data-rt-align=\"center\">\n<div><img decoding=\"async\" src=\"https:\/\/webflow-s3.tenten.co\/2024\/04\/64b94af088e591e7f60e07bc_5e39eb00352b1438e736db71_hgwjltijxlk8lb7uinqs6tupbjg9qrmerkqrrq7zgjuobt96esyjgwbuivoloaaz3l4myjgq5hevng0v-eof48rhx0on_otqcsrh026mp6bitjqlonyym3mjbwxh-y2uhu7p_bzk.gif\" title=\"64b94af088e591e7f60e07bc_5e39eb00352b1438e736db71_hgwjltijxlk8lb7uinqs6tupbjg9qrmerkqrrq7zgjuobt96esyjgwbuivoloaaz3l4myjgq5hevng0v-eof48rhx0on_otqcsrh026mp6bitjqlonyym3mjbwxh-y2uhu7p_bzk\"><\/div>\n<\/figure>\n<p><\/p>\n<p>Due to each section&#8217;s height matching our viewport, let&#8217;s adjust the size of our cardboard box to be quite small (about 100 pixels).<\/p>\n<figure class=\"w-richtext-figure-type-image w-richtext-align-center\" data-rt-type=\"image\" data-rt-align=\"center\">\n<div><img decoding=\"async\" src=\"https:\/\/webflow-s3.tenten.co\/2024\/04\/64b94af088e591e7f60e07b8_5e39eb009e8e9742b6e5bc52_2nzbkcdrgcjxpoz9r6jvlpgh5a6miks02dlniqlu5qlfewbhdqmcenl0ect6usrctulrs2kjwvxeesepg6vgyd9tgiibeampjdirfkbklqgg_pcrtsj1eofpm66louqk73rxmrmx.gif\" title=\"64b94af088e591e7f60e07b8_5e39eb009e8e9742b6e5bc52_2nzbkcdrgcjxpoz9r6jvlpgh5a6miks02dlniqlu5qlfewbhdqmcenl0ect6usrctulrs2kjwvxeesepg6vgyd9tgiibeampjdirfkbklqgg_pcrtsj1eofpm66louqk73rxmrmx\"><\/div>\n<\/figure>\n<p><\/p>\n<p>First step completed! Let&#8217;s move on to setting up the trigger.\u00a0<\/p>\n<h2>Establish the trigger<\/h2>\n<p>Prior to adding our trigger, we need to ensure that the animation (and not another element) is selected.<\/p>\n<figure class=\"w-richtext-figure-type-image w-richtext-align-center\" data-rt-type=\"image\" data-rt-align=\"center\">\n<div><img decoding=\"async\" src=\"https:\/\/webflow-s3.tenten.co\/2024\/04\/64b94af088e591e7f60e07b5_5e39eafed0602129e184f755_sfvbyr5mbingsuh3o4bcdpdtwpkgwkl3ergpmxr6hcoyv25pwj-zeh95cpnnzqdq9dmhfrp0lve_nd774-yx75ejktstxcorb-4lyn3k2daeqlpswxdc6uckpdyga7vd85sv1c8d.gif\" title=\"64b94af088e591e7f60e07b5_5e39eafed0602129e184f755_sfvbyr5mbingsuh3o4bcdpdtwpkgwkl3ergpmxr6hcoyv25pwj-zeh95cpnnzqdq9dmhfrp0lve_nd774-yx75ejktstxcorb-4lyn3k2daeqlpswxdc6uckpdyga7vd85sv1c8d\"><\/div>\n<\/figure>\n<p><\/p>\n<p>We desire the animation to be activated when the selected element (our Lottie animation, the box) enters the viewport. Within the Interactions panel in the right toolbar, open the Element trigger menu and select Scroll into view.<\/p>\n<figure class=\"w-richtext-figure-type-image w-richtext-align-center\" data-rt-type=\"image\" data-rt-align=\"center\">\n<div><img decoding=\"async\" src=\"https:\/\/webflow-s3.tenten.co\/2024\/04\/64b94af088e591e7f60e07a9_5e39eaffd06021ade584f756_5xb68wqvdwgc9_h_fgkvhhlnsg48zahdepn-xe2p5vv9swn1pnztondrrgb681by7etxb0cj7anrd0g94lx3mkksrzfy-qdwpovc_siztvpg0r3qxsbdnqcj-a7zk3r52barhrm.gif\" title=\"64b94af088e591e7f60e07a9_5e39eaffd06021ade584f756_5xb68wqvdwgc9_h_fgkvhhlnsg48zahdepn-xe2p5vv9swn1pnztondrrgb681by7etxb0cj7anrd0g94lx3mkksrzfy-qdwpovc_siztvpg0r3qxsbdnqcj-a7zk3r52barhrm\"><\/div>\n<\/figure>\n<p><\/p>\n<p>Remain in the Interactions panel to configure the animation in our final step.\u00a0<\/p>\n<h2>Configure the animation<\/h2>\n<p>Once our selected element is in view, we want the Lottie animation to start playing.\u00a0<\/p>\n<p>In the Interactions panel under When scrolled into view, select Lottie Playback from the Action menu.\u00a0<\/p>\n<figure class=\"w-richtext-figure-type-image w-richtext-align-center\" data-rt-type=\"image\" data-rt-align=\"center\">\n<div><img decoding=\"async\" src=\"https:\/\/webflow-s3.tenten.co\/2024\/04\/64b94af088e591e7f60e07a5_5e39eafd414eda9f7c3c2bd6_bgrfcftps_ysgff7qphhgt6kqw8fo7_bhli9k-3t014gibmrsoricsnfbwohpi2cmyhiiwrddxinlhddmgda5m5tpgmlbe8h8trn77viohzyd0d3xgvvlhkltrdtsdxr8frmycik.gif\" title=\"64b94af088e591e7f60e07a5_5e39eafd414eda9f7c3c2bd6_bgrfcftps_ysgff7qphhgt6kqw8fo7_bhli9k-3t014gibmrsoricsnfbwohpi2cmyhiiwrddxinlhddmgda5m5tpgmlbe8h8trn77viohzyd0d3xgvvlhkltrdtsdxr8frmycik\"><\/div>\n<\/figure>\n<p>Upon scrolling back to the beginning of the page and clicking preview (the eye icon at the top left corner), you will observe the cardboard box opening as it enters the view \u2014 as expected. However, scrolling back up and then down will still keep the box in an open state.\u00a0<\/p>\n<p>Thus, our next step involves configuring our Lottie animation to play forward and then reverse (so the box reverts to a closed state) when the box scrolls back out of view. To accomplish this, in the Interactions panel under When scrolled out of view, select Lottie Playback from the Action menu. To animate the box back into a closed state, choose Reverse.<\/p>\n<figure class=\"w-richtext-figure-type-image w-richtext-align-center\" data-rt-type=\"image\" data-rt-align=\"center\">\n<div><img decoding=\"async\" src=\"https:\/\/webflow-s3.tenten.co\/2024\/04\/64b94af088e591e7f60e07b1_5e39eb02d0602128ee84f76c_0jrow42he2h794yszogwvaxv5ev6uuxslq3iau4nccyb23skzsm05jpwwkbus_mqplh1v47q-oejeekxhk9xcxyvlrzof7qyvvqjxqnpty6tjqbhq6xia-ctcwkcx3fqzqp8owcv.gif\" title=\"64b94af088e591e7f60e07b1_5e39eb02d0602128ee84f76c_0jrow42he2h794yszogwvaxv5ev6uuxslq3iau4nccyb23skzsm05jpwwkbus_mqplh1v47q-oejeekxhk9xcxyvlrzof7qyvvqjxqnpty6tjqbhq6xia-ctcwkcx3fqzqp8owcv\"><\/div>\n<\/figure>\n<p>After all this effort, we must ensure that this animation doesn&#8217;t go unnoticed \u2014 let&#8217;s introduce an offset so the animation triggers only when it reaches a specific point on the page. While still within the Interactions panel, include a 10% Offset for both <em>When scrolled into view<\/em> and <em>When scrolled out of view<\/em>.<\/p>\n<figure class=\"w-richtext-figure-type-image w-richtext-align-center\" data-rt-type=\"image\" data-rt-align=\"center\">\n<div><img decoding=\"async\" src=\"https:\/\/webflow-s3.tenten.co\/2024\/04\/64b94af088e591e7f60e07a0_5e39eb05feeffa26c4a694db_gqyhss-cu5ke7uysbynakxokud1a3z6-hoecwqf52b6vw3egaj1eiegv3qu5wiph2hz0ze6liq4pjm1dvd_n6lktkkrdut3hn3pq90tfuphek0nus5vrnqmqcafim_c5bi8l6gdf.gif\" title=\"64b94af088e591e7f60e07a0_5e39eb05feeffa26c4a694db_gqyhss-cu5ke7uysbynakxokud1a3z6-hoecwqf52b6vw3egaj1eiegv3qu5wiph2hz0ze6liq4pjm1dvd_n6lktkkrdut3hn3pq90tfuphek0nus5vrnqmqcafim_c5bi8l6gdf\"><\/div>\n<\/figure>\n<p><\/p>\n<p>Now, when you hit preview, start from the top and scroll a bit, and you&#8217;ll notice the box remains closed&#8230; until it hits that 10% threshold, triggering it to open. Furthermore, if you scroll back to the point where it goes out of view, the animation will play in reverse once it reaches the 10% mark, exactly as we instructed it to. Well done!<\/p>\n<figure class=\"w-richtext-figure-type-image w-richtext-align-center\" data-rt-type=\"image\" data-rt-align=\"center\">\n<div><img decoding=\"async\" src=\"https:\/\/webflow.tenten.co\/wp-content\/uploads\/2024\/04\/64b94af088e591e7f60e07ae_5e39eb04d060210d7d84f774_r9nh6-wjztzlg_8iuoq2whxqu28sw0orf4c7_bosrtspvtfx8jyd19oeu8hw-pkcmh9gvqysa8ka5sgk11nbac_l9asrl_rx_6j9vtaubmrbsjmawx_yin_cajlhujij2gvh7jug\"><\/div>\n<\/figure>\n<p><\/p>\n<p>We have added a Lottie animation, chosen our scroll-based trigger, and configured two animations: one for scrolling into view and the other for scrolling out of view. This means you have successfully set up an element to animate as it comes into and goes out of view.<\/p>\n<p>Celebration time!<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"Set up an After Effects animation to animate when it scrolls into view.","protected":false},"author":2,"featured_media":5867,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"om_disable_all_campaigns":false,"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"csco_display_header_overlay":false,"csco_singular_sidebar":"","csco_page_header_type":"","footnotes":""},"categories":[301],"tags":[],"class_list":{"0":"post-5866","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-interactions-animations","8":"cs-entry"},"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/webflow.tenten.co\/en\/wp-json\/wp\/v2\/posts\/5866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webflow.tenten.co\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webflow.tenten.co\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webflow.tenten.co\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/webflow.tenten.co\/en\/wp-json\/wp\/v2\/comments?post=5866"}],"version-history":[{"count":0,"href":"https:\/\/webflow.tenten.co\/en\/wp-json\/wp\/v2\/posts\/5866\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webflow.tenten.co\/en\/wp-json\/wp\/v2\/media\/5867"}],"wp:attachment":[{"href":"https:\/\/webflow.tenten.co\/en\/wp-json\/wp\/v2\/media?parent=5866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webflow.tenten.co\/en\/wp-json\/wp\/v2\/categories?post=5866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webflow.tenten.co\/en\/wp-json\/wp\/v2\/tags?post=5866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}