{"id":3886,"date":"2018-10-31T15:34:44","date_gmt":"2018-10-31T15:34:44","guid":{"rendered":"http:\/\/freshinbox.com\/blog\/?p=3886"},"modified":"2018-10-31T15:41:13","modified_gmt":"2018-10-31T15:41:13","slug":"full-page-intro-animations-in-email","status":"publish","type":"post","link":"https:\/\/freshinbox.com\/blog\/full-page-intro-animations-in-email\/","title":{"rendered":"Full Page Intro Animations in Email"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/freshinbox.com\/blog\/wp-content\/uploads\/2018\/10\/soccer2.gif\" alt=\"\" width=\"400\"  class=\"aligncenter size-full wp-image-3889\" style=\"max-width:100%\" \/><\/p>\n<p><center><a href=\"https:\/\/codepen.io\/freshinbox\/pen\/ZqdeKp\" rel=\"noopener\" target=\"_blank\"><b>View live example<\/b><\/a><\/center><\/p>\n<p>This is a simple technique to show a brief animation of an object or text against a blank page and having the rest of the email &#8220;fade in&#8221; after the animation ends. This is a follow on of a previous example with <a href=\"https:\/\/freshinbox.com\/blog\/fade-in-text-effects-for-email\/\">fade in text animation<\/a>. <\/p>\n<p>I got the inspiration from <a href=\"https:\/\/www.apple.com\/macbook\/\" rel=\"noopener\" target=\"_blank\">Apple&#8217;s MacBook website<\/a> featuring a Macbook appearing over a blank page. This technique is supported by the email clients that support CSS animation &#8211; namely the iOS email clients (iPhone, iPad), Apple Mail and Samsung Mail. For other clients, the object or text will appear as static.<BR><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/freshinbox.com\/blog\/wp-content\/uploads\/2018\/10\/macbook2.gif\" alt=\"\" width=\"600\"  class=\"aligncenter size-full wp-image-3891\" style=\"max-width:100%\" \/><BR><\/p>\n<p>This technique is relatively straightforward to implement and if a significant number of your subscribers are on a capable email client, this will be a cool way to delight them.<BR><BR><\/p>\n<h2>Soccer ball intro<\/h2>\n<p>In our example, we use an image of a soccer ball lowering onto a shadow. Non supported clients will just see a ball without a shadow although you could swap in an image of a different soccer ball with the shadow if you prefer.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/freshinbox.com\/blog\/wp-content\/uploads\/2018\/10\/football-pixabay-200x200.png\" alt=\"\" width=\"200\" \/><br \/>\n<i>Soccer Image<\/i><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/freshinbox.com\/blog\/wp-content\/uploads\/2018\/10\/football-shadow.png\" alt=\"\" width=\"250\" height=\"100\"  \/><br \/>\n<i>Shadow Image<\/i><\/p>\n<p>Lets start with the following code to make the ball drop, we stack the ball and shadow on top of each other and we give each their own animation.<\/p>\n<p>The ball gets a <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/transform-function\/translate\" rel=\"noopener\" target=\"_blank\">translate<\/a> and opacity transformation, which will make it appear 30 pixels above its existing position and move it 30 pixels under, which will make it overlap with the shadow. Adding a z-index allows it to appear over the shadow.<\/p>\n<pre class=\"lang:default decode:true \" >.ball{\r\n  z-index:100;\r\n  animation: drop 4s forwards;\r\n  position:relative;\r\n}\r\n@keyframes drop{\r\n  0%{\r\n    opacity:0;\r\n  }\r\n  25%{\r\n    opacity:0;\r\n    transform:translateY(-30px);    \r\n  }\r\n  80%{\r\n    opacity:0.9;\r\n  }\r\n  100%{  \r\n    opacity:1;\r\n    transform:translateY(30px);\r\n  }\r\n}<\/pre>\n<p>As for the shadow, we use an opacity and scale transform which makes it grow as it appears under the ball.<\/p>\n<pre class=\"lang:default decode:true \" >.ball-shadow{\r\n  animation: shadow 4s forwards;\r\n  position:relative;\r\n}\r\n@keyframes shadow{\r\n  0%{\r\n    opacity:0;\r\n  }\r\n  40%{\r\n    opacity:0;\r\n    transform: scale(0.8);    \r\n  }\r\n  100%{  opacity:1;\r\n    transform: scale(1);    \r\n  }\r\n}<\/pre>\n<h4>Hiding and showing the rest of the email<\/h4>\n<p>To hide the rest of the page initially we wrap them with a container and assign a class &#8220;showlater&#8221; that intially has the opacity set to 0. It is important that the container not wrap the animated content or everything will be hidden! Therefore you need at least two blocks, one above and one below the animated content.<\/p>\n<p>We then assign an animation that displays the hidden content with a preset delay (5 seconds).<\/p>\n<pre class=\"lang:default decode:true \" >.showlater{\r\n  opacity:0;\r\n  animation: showlater 0.8s 5s forwards;\r\n}\r\n@keyframes showlater{\r\n  from{\r\n   opacity:0;\r\n  }\r\n  to{\r\n   opacity:1;\r\n  }\r\n}\r\n<\/pre>\n<h2>Fallback<\/h2>\n<p>Since not all clients support CSS animations, we need to take the less capable clients into account. Luckily in this case all we need is to hide the shadow (we can leave it in as well).<\/p>\n<p>The <a href=\"https:\/\/freshinbox.com\/blog\/bulletproof-solution-to-hiding-mobile-content-when-opened-in-non-mobile-email-clients\/\">following code<\/a> initially hides the shadow from all email clients.<\/p>\n<pre class=\"lang:default decode:true \" >&lt;!--[if !mso]&gt;&lt;!--&gt;\r\n&lt;div class=\"ball-shadow\" style=\"display:none;max-height:0px;overflow:hidden;\"&gt;&lt;img src=\"ball-shadow.png\" width=\"250\" height=\"60\"&gt;&lt;\/div&gt;\r\n&lt;!--&lt;![endif]--&gt;<\/pre>\n<p>We then place the following code within a-webkit-min-device-pixel-ratio media query that only clients that support CSS animations will process as <a href=\"https:\/\/www.emailonacid.com\/blog\/article\/email-development\/four-interactive-email-fallback-strategies\/\" rel=\"noopener\" target=\"_blank\">explained in this article<\/a>.<\/p>\n<pre class=\"lang:default decode:true \" >@media screen and (-webkit-min-device-pixel-ratio:0){\r\n  .ball-shadow{\r\n    animation: shadow 4s forwards;\r\n    display:block!important;\r\n    max-height:none!important;\r\n    position:relative;\r\n  }\r\n  .ball{\r\n    z-index:100;\r\n    animation: drop 4s forwards;\r\n    position:relative;\r\n  }\r\n  .showlater{\r\n    opacity:0;\r\n    animation: showlater 0.8s 5s forwards;\r\n  }\r\n}<\/pre>\n<h2>Live Example<\/h2>\n<p>See the <a href=\"https:\/\/codepen.io\/freshinbox\/pen\/ZqdeKp\" rel=\"noopener\" target=\"_blank\">full example on CodePen<\/a>.<\/p>\n<h2>Text Animation<\/h2>\n<p>You can also apply this technique to text as well. <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/freshinbox.com\/blog\/wp-content\/uploads\/2018\/10\/text-intro.gif\" alt=\"\" width=\"395\" class=\"aligncenter size-full wp-image-3890\" style=\"max-width:100%\" \/><\/p>\n<p>See the <a href=\"https:\/\/codepen.io\/freshinbox\/pen\/MPMpEj\" rel=\"noopener\" target=\"_blank\">full example on CodePen<\/a>.<\/p>\n<p>Just like the previous animation, for clients that don&#8217;t support support animations, they see the static text. <\/p>\n<p><BR><BR><BR><\/p>\n<div style=\"padding:10px; border: 2px solid #99C731;background-color:#FFF8DC;border-radius:5px;\">\n<form action=\"https:\/\/freshinbox1.createsend.com\/t\/i\/s\/adrmi\/\" method=\"post\" id=\"subForm\">\n<span class=\"fisub_header\" style=\"font-weight:bold;\">Subscribe to the #EmailGeeks Newsletter<\/span>\n<p><input id=\"fieldEmail\" name=\"cm-adrmi-adrmi\" type=\"email\" style=\"width:90%\" required placeholder=\"Your Email Address\" \/><\/p>\n<p><button type=\"submit\">Subscribe<\/button><\/p>\n<\/form>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This is a simple technique to show a brief animation of an object or text against a blank page and having the rest of the email &#8220;fade in&#8221; after the animation ends. This is a follow on of a previous example with <a href=\"http:\/\/freshinbox.com\/blog\/fade-in-text-effects-for-email\/\">fade in text animation<\/a>. <\/p>\n<p>I got the inspiration from <a href=\"https:\/\/www.apple.com\/macbook\/\" rel=\"noopener\" target=\"_blank\">Apple&#8217;s MacBook website<\/a>.<\/p>\n","protected":false},"author":2,"featured_media":3894,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[24,25,47],"tags":[],"_links":{"self":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts\/3886"}],"collection":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/comments?post=3886"}],"version-history":[{"count":24,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts\/3886\/revisions"}],"predecessor-version":[{"id":3915,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/posts\/3886\/revisions\/3915"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/media\/3894"}],"wp:attachment":[{"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/media?parent=3886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/categories?post=3886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freshinbox.com\/blog\/wp-json\/wp\/v2\/tags?post=3886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}