{"id":1602,"date":"2017-07-08T00:29:36","date_gmt":"2017-07-08T00:29:36","guid":{"rendered":"http:\/\/websterart.com\/wordpress\/?page_id=1602"},"modified":"2020-01-13T20:46:36","modified_gmt":"2020-01-13T20:46:36","slug":"animated-banner-tutorial-part-2","status":"publish","type":"page","link":"https:\/\/websterart.com\/wordpress\/animated-banner-tutorial-part-2\/","title":{"rendered":"Animated Banner Tutorial Part 2"},"content":{"rendered":"<p>This is part 2, if you are looking for part 1, <a href=\"http:\/\/websterart.com\/wordpress\/html-5-animated-banner-tutorial\/\">it is here<\/a>.<\/p>\n<h3>Sliding Reveal<\/h3>\n<p>Open <strong>banner-done.html<\/strong> and drag the playhead slider over until you see the white rectangle slide out from underneath the diagonal gray band.<\/p>\n<p><a class=\"single_photoswipe\" href=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress8.png\" data-size=\"1880x442\"><img decoding=\"async\" class=\"aligncenter wp-image-1608 size-thumbnail\" src=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress8-150x35.png\" alt=\"wordpress8\" width=\"150\" height=\"35\" srcset=\"https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress8-150x35.png 150w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress8-300x71.png 300w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress8-1800x423.png 1800w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress8-400x94.png 400w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress8-500x118.png 500w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress8-600x141.png 600w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress8-1276x300.png 1276w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress8-768x181.png 768w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress8-180x42.png 180w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress8.png 1880w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a><\/p>\n<p>To get all this to work we have to configure and style half a dozen different elements that currently don&#8217;t exist. The white rectangle (called <span class=\"highlight\">#potato<\/span>) with rounded corners is fairly obvious. But getting it to slide out from underneath a slanted rectangle (called <span class=\"highlight\">#trapazoid2<\/span>) means there has to be a slanted rectangle, and the rectangle has to exist on a higher level or layer (called z-index in CSS) than the white rectangle. And the slanted rectangle has to be big enough to cover the white rectangle, while simultaneously the white rectangle has to be wider than the slanted rectangle after it slides into view. It&#8217;s a lot to think about, but we will tackle it in stages.<\/p>\n<p><span class=\"colored-step\"><strong>STEP ONE<\/strong>:<\/span> Lets get the trapazoid2 and potato in place. Open <strong>banner-start.html<\/strong> and add two new elements called trapazoid2 and potato. It is lines 14 &amp; 15 below:<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;!--this is banner-start.html--&gt; \r\n&lt;div id=\"banner\"&gt; \r\n   &lt;div id=\"pitchWrapper\"&gt; \r\n\t     &lt;div id=\"quote\"&gt; \r\n\t     \tWe make the best Mufflers \r\n\t     &lt;\/div&gt; \r\n\t     &lt;div id=\"bouncyGreen\"&gt;\r\n\t       in Tacoma \r\n\t     &lt;\/div&gt; \r\n\t&lt;\/div&gt;&lt;!--end pitchWrapper div--&gt; \r\n\t&lt;img src=\"images\/simon2.png\" alt=\"simon\" id=\"simon\"&gt;\r\n\t&lt;h1 id=\"callUs\"&gt;Call our Cellphone:&lt;\/h1&gt;\r\n\t&lt;h2 id=\"phoneNumber\"&gt;253-234-5678&lt;\/h2&gt;\r\n\t&lt;div id=\"trapazoid2\"&gt;&lt;\/div&gt;&lt;!-- new code --&gt;\r\n\t&lt;div id=\"potato\"&gt;&lt;\/div&gt;\t&lt;!-- new code --&gt;    \r\n &lt;\/div&gt;&lt;!--end banner div--&gt;<\/pre>\n<p><strong><span class=\"colored-step\">STEP TWO:<\/span><\/strong> On <strong>banner-start.css<\/strong>, add these two new rules below the other rules. Save your changes to both the html and css and view the animation.<\/p>\n<pre class=\"lang:css decode:true \">\/*banner-start.css*\/\r\n#trapazoid2{\r\n\tbackground-color: #f00;\r\n\tposition:absolute;\r\n\tleft:39px;\r\n\ttop:0;\r\n\theight:90px;\r\n\twidth:340px;\r\n\tmargin:0;\r\n\tpadding:0;\r\n\t-moz-transform: skew(-22deg, 0deg);\r\n\t-webkit-transform: skew(-22deg, 0deg);\r\n\t-o-transform: skew(-22deg, 0deg);\r\n\t-ms-transform: skew(-22deg, 0deg);\r\n\ttransform: skew(-22deg, 0deg);\r\n\topacity:0.5;\r\n\tz-index: 5;\r\n}\r\n\r\n#potato {\r\n  height: 90px;\r\n  width: 450px;\r\n  background-color: #fff;\r\n  -webkit-border-radius: 15px;\r\n  -moz-border-radius: 15px;\r\n  border-radius: 15px;\r\n  position:absolute;\r\n  left:20px;\r\n  top:0;\r\n   -ms-transform: scale(0.5,1); \/* IE 9 *\/\r\n   -webkit-transform: scale(0.5,1); \/* Safari *\/\r\n   transform: scale(0.5,1); \/* Standard syntax *\/\r\n  \/*opacity: 0;*\/\r\n  z-index: 2;\r\n}<\/pre>\n<p>This is what you will see after it has finished running:<\/p>\n<p><a class=\"single_photoswipe\" href=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress9.png\" data-size=\"1646x296\"><img decoding=\"async\" class=\"aligncenter wp-image-1610 size-thumbnail\" src=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress9-150x27.png\" alt=\"wordpress9\" width=\"150\" height=\"27\" srcset=\"https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress9-150x27.png 150w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress9-768x138.png 768w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress9-180x32.png 180w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress9-300x54.png 300w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress9-600x108.png 600w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress9.png 1646w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a>The style sheet is telling trapazoid2 to be temporarily red and transparent. This allows us to see the potato underneath it for testing. The potato has also been transformed horizontally (but not vertically) <span class=\"highlight\">transform: scale(0.5,1);<\/span> to half it&#8217;s normal width. This allows it to hide under the smaller trapazoid2 until it is needed.<\/p>\n<p>To generate the transform properties, this website has a cool interactive code generator:<\/p>\n<p><a href=\"http:\/\/www.css3maker.com\/css3-transform.html\">http:\/\/www.css3maker.com\/css3-transform.html<\/a><\/p>\n<p><strong><span class=\"colored-step\">STEP THREE:<\/span><\/strong> To make this project easier to understand, I&#8217;ve built a pdf that shows something close to what could be called storyboards. <a href=\"http:\/\/websterart.com\/video\/storyboard4.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">Open this pdf<\/a>. I&#8217;m also embedding it in this site, but the pdf has better image quality.<\/p>\n<p><a class=\"single_photoswipe\" href=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress-10.png\" data-size=\"1768x1910\"><img decoding=\"async\" class=\"aligncenter wp-image-1612 size-medium\" src=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress-10-278x300.png\" alt=\"wordpress-10\" width=\"278\" height=\"300\" srcset=\"https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress-10-278x300.png 278w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress-10-150x162.png 150w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress-10-768x830.png 768w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress-10-948x1024.png 948w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress-10-167x180.png 167w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress-10-555x600.png 555w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress-10.png 1768w\" sizes=\"(max-width: 278px) 100vw, 278px\" \/><\/a><\/p>\n<p>The first time I taught this lesson to my students I had not built this storyboard. To say they were confused is an understatement. The most important thing to study here is the <span class=\"highlight\">z-index<\/span> settings for all the stacked up elements. Keep in mind that you can only apply <strong>z-index<\/strong> to an element that has been positioned, as in <span class=\"highlight\">position: absolute, relative, fixed<\/span>, etc.<\/p>\n<p><strong><span class=\"colored-step\">STEP FOUR:<\/span><\/strong> Open <strong>banner-start.js<\/strong> and add this new line of code to the bottom (line 11). It will animate the #potato over into place. It works by scaling up the width to 100% and changing it&#8217;s location to an x value of 330: <span class=\"highlight\">x:330, scaleX:1<\/span>. To return to the lipstick analogy, the lipstick just moved out of the tube and is ready to use.<\/p>\n<pre class=\"lang:java decode:true \">\/\/ this is banner-start.js\r\nvar mySplitText = new SplitText(\"#quote\", {type:\"words\"});\r\nvar tl = new TimelineMax();\r\ntl.to(\"#banner\", 1.5, {opacity:1, ease:Cubic.easeOut})\r\n.staggerFrom(mySplitText.words, 0.3, {opacity:0, scale:0.4,  ease:Back.easeOut}, 0.15)\r\n.from(\"#bouncyGreen\", 0.9,{opacity:0, y:50, ease:Elastic.easeOut, delay:0.5})\r\n.to(\"#pitchWrapper\", 1, {opacity:0, scale:0.3, y:22, ease:Back.easeIn, delay:0.5})\r\n.from(\"#callUs\", 0.5,{x:-430, ease:Cubic.easeOut, delay:0.5})\r\n.from(\"#phoneNumber\", 0.5,{x:-430, ease:Cubic.easeOut},\"-=0.4\")\r\n.from(\"#simon\", 0.5,{x:-100, ease:Cubic.easeOut},\"-=0.4\")\r\n.to(\"#potato\", 0.7,{x:330, scaleX:1, ease:Cubic.easeOut})<\/pre>\n<p><a class=\"single_photoswipe\" href=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress11.png\" data-size=\"1626x198\"><img decoding=\"async\" class=\"aligncenter wp-image-1625 size-thumbnail\" src=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress11-150x18.png\" alt=\"wordpress11\" width=\"150\" height=\"18\" srcset=\"https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress11-150x18.png 150w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress11-768x94.png 768w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress11-180x22.png 180w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress11-300x37.png 300w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress11-600x73.png 600w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress11.png 1626w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a><\/p>\n<p><strong><span class=\"colored-step\">STEP FIVE:<\/span><\/strong> Now that we know our <strong>#potato<\/strong> is hiding and animating correctly, lets make the <strong>#trapazoid2<\/strong> element fully opaque, and set it&#8217;s background color to the same as the <strong>#banner<\/strong>. We want it there to hide the #potato, but it should blend into the background&#8230;like a flesh colored bandaid over a blemish. Open <strong>banner-start.css<\/strong> and modify the\u00a0 opacity and background-color settings. Also, add a rule that gives the <strong>#pitchWrapper<\/strong> a z-index setting of 9.<\/p>\n<pre class=\"lang:css decode:true \">\/*this is banner-start.css*\/\r\n#trapazoid2{\r\n\tbackground-color: #333;\/* new code *\/\r\n\tposition:absolute;\r\n\tleft:39px;\r\n\ttop:0;\r\n\theight:90px;\r\n\twidth:340px;\r\n\tmargin:0;\r\n\tpadding:0;\r\n\t-moz-transform: skew(-22deg, 0deg);\r\n\t-webkit-transform: skew(-22deg, 0deg);\r\n\t-o-transform: skew(-22deg, 0deg);\r\n\t-ms-transform: skew(-22deg, 0deg);\r\n\ttransform: skew(-22deg, 0deg);\r\n\topacity:1;\/* new code *\/\r\n\tz-index: 5;\r\n}\r\n#pitchWrapper{\/* new rule *\/\r\n position:absolute;\r\n left:0;\r\n top:0;\r\n z-index: 9;\r\n}<\/pre>\n<p>With that we are getting quite close. All we are missing is the 3 elements that slide out from under the #trapazoid2. They need to be configured so that they are under #trapazoid2, but over the #potato. We will do that with z-index settings. First we have to get them in there with HTML markup, and then hide them with CSS.<\/p>\n<p><strong><span class=\"colored-step\">STEP SIX:<\/span> <\/strong>On <strong>banner-start.html<\/strong>, add the following 3 new elements, lines 15 thru 19 below:<\/p>\n<pre class=\"lang:xhtml decode:true \">&lt;div id=\"banner\"&gt;\r\n\t&lt;div id=\"pitchWrapper\"&gt;\r\n\t\t&lt;div id=\"quote\"&gt;\r\n\t\t\tWe make the best Mufflers \r\n\t\t&lt;\/div&gt;\r\n\t\t&lt;div id=\"bouncyGreen\"&gt;\r\n\t\t\tin Tacoma\r\n\t\t&lt;\/div&gt;\r\n\t&lt;\/div&gt;&lt;!--end pitchWrapper div--&gt;\r\n\t&lt;img src=\"images\/simon2.png\" alt=\"simon\" id=\"simon\"&gt;\r\n\t&lt;h1 id=\"callUs\"&gt;Call our Cellphone:&lt;\/h1&gt;\r\n\t&lt;h2 id=\"phoneNumber\"&gt;253-234-5678&lt;\/h2&gt;\r\n\t&lt;div id=\"trapazoid2\"&gt;&lt;\/div&gt;\r\n\t&lt;div id=\"potato\"&gt;&lt;\/div&gt;\r\n\t&lt;h1 id=\"theDate\"&gt;September 22&lt;\/h1&gt;&lt;!-- new code --&gt;\r\n\t&lt;div id=\"description\"&gt;&lt;!-- new code --&gt;\r\n\t\tWatch us weld custom Stainless Steel mufflers for your Honda Civic  \r\n\t&lt;\/div&gt;\r\n\t&lt;a href=\"http:\/\/www.websterart.com\" id=\"signUp\"&gt;Sign Up Today!&lt;\/a&gt; &lt;!-- new code --&gt;\r\n\r\n&lt;\/div&gt;&lt;!--end banner div--&gt;<\/pre>\n<p><strong><span class=\"colored-step\">STEP SEVEN:<\/span> <\/strong>On <strong>banner-start.css<\/strong>, add these three new rules below all the other rules. There is a lot of code this time because the button <span class=\"highlight\">a#signUp<\/span> is made with CSS 3 gradients:<\/p>\n<pre class=\"lang:css decode:true\">h1#theDate {\r\n\tfont-family: Arial, Helvetica, sans-serif;\r\n\tfont-size: 2em;\r\n\tcolor:#333;\r\n\tposition:absolute;\r\n\tleft: 200px;\r\n\ttop:0px;\r\n\tmargin:0;\r\n\tpadding:0;\r\n\tz-index: 3;\r\n}\r\n\r\n#description {\r\n\tposition:absolute;\r\n\tleft:150px;\r\n\ttop:31px;\r\n\tmargin:0;\r\n\tpadding:0;\t\r\n\tcolor:#9E5111;\r\n\twidth:200px;\r\n\tz-index: 4;\r\n}\r\n#banner a#signUp {\r\n\tdisplay:block;\r\n\tposition:absolute;\r\n\ttop:15px;\r\n\tright:20px;\r\n\tcolor: rgb(230, 230, 230);\r\n\tfont-size: 1.2em;\r\n\ttext-decoration: none;\r\n\tpadding: 15px;\r\n\ttext-shadow: 0px -1px 0px rgba(30, 30, 30, 0.8);\r\n\t-webkit-border-radius: 19.864864864864863px;\r\n\t-moz-border-radius: 19.864864864864863px;\r\n\tborder-radius: 19.864864864864863px;\r\n\tbackground: rgb(176, 1, 42);\r\n\tbackground: -moz-linear-gradient(90deg, rgb(176, 1, 42) 30%, rgb(250, 20, 0) 70%);\r\n\tbackground: -webkit-linear-gradient(90deg, rgb(176, 1, 42) 30%, rgb(250, 20, 0) 70%);\r\n\tbackground: -o-linear-gradient(90deg, rgb(176, 1, 42) 30%, rgb(250, 20, 0) 70%);\r\n\tbackground: -ms-linear-gradient(90deg, rgb(176, 1, 42) 30%, rgb(250, 20, 0) 70%);\r\n\tbackground: linear-gradient(0deg, rgb(176, 1, 42) 30%, rgb(250, 20, 0) 70%);\r\n\t-webkit-box-shadow: 5px 8px 7px rgba(50, 50, 50, 0.75);\r\n\t-moz-box-shadow:    5px 8px 7px rgba(50, 50, 50, 0.75);\r\n\tbox-shadow:         5px 8px 7px rgba(50, 50, 50, 0.75);\r\n   -ms-transform: scale(0.3,0.3); \/* IE 9 *\/\r\n   -webkit-transform: scale(0.3,0.3); \/* Safari *\/\r\n   transform: scale(0.3,0.3); \/* Standard syntax *\/\r\n\/*http:\/\/css3gen.com\/button-generator\/*\/\r\n\topacity:0;\r\n\tz-index: 10;\r\n\r\n}<\/pre>\n<p>Note that you can&#8217;t see them. It is helpful to be able to see them in case you need to tweak their position when you use different text copy.<\/p>\n<p><strong><span class=\"colored-step\">STEP EIGHT:<\/span><\/strong> On <strong>banner-start.css<\/strong>, make the <strong>#trapazoid2<\/strong> transparent and red, also temporarily change the background color of <strong>#banner<\/strong> to a butterscotch color (not shown):<\/p>\n<pre class=\"lang:css decode:true \">#trapazoid2{\r\n\tbackground-color: #f00;\/* new code *\/\r\n\tposition:absolute;\r\n\tleft:39px;\r\n\ttop:0;\r\n\theight:90px;\r\n\twidth:340px;\r\n\tmargin:0;\r\n\tpadding:0;\r\n\t-moz-transform: skew(-22deg, 0deg);\r\n\t-webkit-transform: skew(-22deg, 0deg);\r\n\t-o-transform: skew(-22deg, 0deg);\r\n\t-ms-transform: skew(-22deg, 0deg);\r\n\ttransform: skew(-22deg, 0deg);\r\n\topacity:0.5;\/* new code *\/\r\n\tz-index: 5;\r\n}<\/pre>\n<p><strong><span class=\"colored-step\">STEP NINE:<\/span><\/strong> On banner-start.js, add these four new commands, shown as lines 12 to 15below. Save the file and view the animation.<\/p>\n<pre class=\"lang:js decode:true\">\/\/ this is banner-start.js\r\nvar mySplitText = new SplitText(\"#quote\", {type:\"words\"});\r\nvar tl = new TimelineMax();\r\ntl.to(\"#banner\", 1.5, {opacity:1, ease:Cubic.easeOut})\r\n.staggerFrom(mySplitText.words, 0.3, {opacity:0, scale:0.4,  ease:Back.easeOut}, 0.15)\r\n.from(\"#bouncyGreen\", 0.9,{opacity:0, y:50, ease:Elastic.easeOut, delay:0.5})\r\n.to(\"#pitchWrapper\", 1, {opacity:0, scale:0.3, y:22, ease:Back.easeIn, delay:0.5})\r\n.from(\"#callUs\", 0.5,{x:-430, ease:Cubic.easeOut, delay:0.5})\r\n.from(\"#phoneNumber\", 0.5,{x:-430, ease:Cubic.easeOut},\"-=0.4\")\r\n.from(\"#simon\", 0.5,{x:-100, ease:Cubic.easeOut},\"-=0.4\")\r\n.to(\"#potato\", 0.7,{x:330, scaleX:1, ease:Cubic.easeOut})\r\n.to(\"#theDate\", 0.5,{x:200, ease:Cubic.easeOut})\r\n.to(\"#description\", 0.5,{x:250, ease:Cubic.easeOut},\"-=0.4\")\r\n.to(\"#signUp\", 0.8,{opacity:1, scale:1, ease:Elastic.easeOut, delay:0.8})\r\n.to(\"#banner\", 0.5,{autoAlpha:0,delay:5});<\/pre>\n<p><a class=\"single_photoswipe\" href=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress13.png\" data-size=\"1626x206\"><img decoding=\"async\" class=\"aligncenter wp-image-1634 size-thumbnail\" src=\"http:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress13-150x19.png\" alt=\"wordpress13\" width=\"150\" height=\"19\" srcset=\"https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress13-150x19.png 150w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress13-300x38.png 300w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress13-400x51.png 400w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress13-500x63.png 500w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress13-600x76.png 600w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress13-768x97.png 768w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress13-180x23.png 180w, https:\/\/websterart.com\/wordpress\/wp-content\/uploads\/2017\/07\/wordpress13.png 1626w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a><\/p>\n<p>The last line in the script above tells the banner to hide after 5 seconds. Typically ads run for two loops, and then stop. You can make them run indefinitely, but that is frowned on as a best practice.<br \/>\n<strong><span class=\"colored-step\">STEP TEN:<\/span><\/strong> On <strong>banner-start.css<\/strong>, change the background color of <strong>#banner<\/strong> back to #333. Also, on <strong>#trapazoid2<\/strong>, change the opacity to 1, and the background-color to #333. View the animation and it should be perfect&#8230;except that it fades out completely&#8230;again, not a perfect user experience.<\/p>\n<p><strong><span class=\"colored-step\">STEP ELEVEN:<\/span><\/strong> On <strong>banner-start.js<\/strong>, modify this line:<br \/>\n<span class=\"highlight\">var tl = new TimelineMax(); <\/span><br \/>\nso that it looks like this:<br \/>\n<span class=\"highlight\">var tl = new TimelineMax({repeat:-1});<\/span><\/p>\n<p>The repeat:-1 tells the animation to loop forever. That is better than it was, but it would be even better if we could tailor the repeats to exactly the number our client requests. For that to work, we have to put a counter in our code that checks to see how many times the animation has looped, and stops it after the desired number of loops.<\/p>\n<p><strong><span class=\"colored-step\">STEP TWELVE:<\/span><\/strong> On <strong>banner-start.js<\/strong>, add two variables called <strong>loop<\/strong>, and <strong>loopMax<\/strong>, shown as lines 4 &amp; 5 below. If you have ever written a for loop, you will know that we set up a statement that initializes the variable value (var loop = 0), compares current value of loop to the max (loopMax &lt; 2), and increments the variable up 1 number (loop plus 1). Then the for loop runs again, repeating\u00a0 the comparing and incrementing.<br \/>\n<span class=\"highlight\"><br \/>\nfor (var i=0, i &lt; 2, i++) {<br \/>\nloop the animation<br \/>\n}<\/span><\/p>\n<pre class=\"lang:js decode:true \">\/\/ this is banner-start.js\r\nvar mySplitText = new SplitText(\"#quote\", {type:\"words\"});\r\nvar tl = new TimelineMax({repeat:-1});\r\nloop =0;\r\nloopMax = 2;\r\ntl.to(\"#banner\", 1.5, {opacity:1, ease:Cubic.easeOut})\r\n.staggerFrom(mySplitText.words, 0.3, {opacity:0, scale:0.4,  ease:Back.easeOut}, 0.15)\r\n.from(\"#bouncyGreen\", 0.9,{opacity:0, y:50, ease:Elastic.easeOut, delay:0.5})\r\n.to(\"#pitchWrapper\", 1, {opacity:0, scale:0.3, y:22, ease:Back.easeIn, delay:0.5})\r\n.from(\"#callUs\", 0.5,{x:-430, ease:Cubic.easeOut, delay:0.5})\r\n.from(\"#phoneNumber\", 0.5,{x:-430, ease:Cubic.easeOut},\"-=0.4\")\r\n.from(\"#simon\", 0.5,{x:-100, ease:Cubic.easeOut},\"-=0.4\")\r\n.to(\"#potato\", 0.7,{x:330, scaleX:1, ease:Cubic.easeOut})\r\n.to(\"#theDate\", 0.5,{x:200, ease:Cubic.easeOut})\r\n.to(\"#description\", 0.5,{x:250, ease:Cubic.easeOut},\"-=0.4\")\r\n.to(\"#signUp\", 0.8,{opacity:1, scale:1, ease:Elastic.easeOut, delay:0.8})\r\n.to(\"#banner\", 0.5,{autoAlpha:0,delay:5});<\/pre>\n<p>&nbsp;<\/p>\n<p><strong><span class=\"colored-step\">STEP THIRTEEN:<\/span><\/strong> On <strong>banner-start.js, <\/strong>insert this command <span class=\"highlight\">.call(loopCheck)<\/span> on an empty line before <span class=\"highlight\">.to(&#8220;#banner&#8221;,&#8230;..)<\/span>, line 17. And also add in the <span class=\"highlight\">function loopCheck(){}.<\/span>, lines 20 thru 30. Save the file and run the animation.<\/p>\n<pre class=\"lang:js decode:true\">\/\/ this is banner-start.js\r\nvar mySplitText = new SplitText(\"#quote\", {type:\"words\"});\r\nvar tl = new TimelineMax({repeat:-1});\r\nloop =0;\r\nloopMax = 2;\r\ntl.to(\"#banner\", 1.5, {opacity:1, ease:Cubic.easeOut})\r\n.staggerFrom(mySplitText.words, 0.3, {opacity:0, scale:0.4,  ease:Back.easeOut}, 0.15)\r\n.from(\"#bouncyGreen\", 0.9,{opacity:0, y:50, ease:Elastic.easeOut, delay:0.5})\r\n.to(\"#pitchWrapper\", 1, {opacity:0, scale:0.3, y:22, ease:Back.easeIn, delay:0.5})\r\n.from(\"#callUs\", 0.5,{x:-430, ease:Cubic.easeOut, delay:0.5})\r\n.from(\"#phoneNumber\", 0.5,{x:-430, ease:Cubic.easeOut},\"-=0.4\")\r\n.from(\"#simon\", 0.5,{x:-100, ease:Cubic.easeOut},\"-=0.4\")\r\n.to(\"#potato\", 0.7,{x:330, scaleX:1, ease:Cubic.easeOut})\r\n.to(\"#theDate\", 0.5,{x:200, ease:Cubic.easeOut})\r\n.to(\"#description\", 0.5,{x:250, ease:Cubic.easeOut},\"-=0.4\")\r\n.to(\"#signUp\", 0.8,{opacity:1, scale:1, ease:Elastic.easeOut, delay:0.8})\r\n.call(loopCheck)\r\n.to(\"#banner\", 0.5,{autoAlpha:0,delay:5});\r\n\r\nfunction loopCheck(){\r\n\t\/\/console.log(\"loopCheck\")\r\n\tloop++;\r\n\tif (loop &lt; loopMax) {\r\n\t\t\/\/console.log(\"play again\")\r\n\t\ttl.play();\r\n\t} else{\r\n\t\t\/\/console.log(\"done\")\r\n\t\ttl.pause();\r\n\t}\r\n}<\/pre>\n<p>By inserting the <span class=\"highlight\">.call(loopCheck)<\/span> command before the <span class=\"highlight\">.to(&#8220;#banner&#8221;)<\/span> command, we allow our counter to do a quick check of how many loops have happened. If the loop variable value has been incremented up to a value of 2, the loopCheck function cycles through to the else statement, which tells the timeline (<span class=\"highlight\">tl<\/span>) to pause before gettting to the last command. This leaves our banner visible for someone to click the button&#8230;now that all the motion has stopped.<\/p>\n<p><strong><span class=\"colored-step\">STEP FOURTEEN:<\/span><\/strong> The button is already clickable, but wouldn&#8217;t it be nice if we could attach a cute little animation to the hover state? As the greensock people would say: &#8220;No problem!&#8221;. Add this new code to the top of <strong>banner-start.js<\/strong>. This code finds the element with the <strong>#signUp<\/strong> id, which is the red button, and tells it to have a handy little roll-over, roll-off effect.<\/p>\n<pre class=\"lang:js decode:true \">register = document.getElementById(\"signUp\");\r\n\r\nsignUp.onmouseenter = function() {\r\n  TweenLite.to(signUp, 0.2, {scale:1.2})\r\n}\r\n\r\nsignUp.onmouseleave = function() {\r\n  TweenLite.to(signUp, 0.2, {scale:1})\r\n}<\/pre>\n<h3>Nice Work!<\/h3>\n<p>You now have a functioning horizontal banner ad. It&#8217;s not responsive&#8230;so if that causes problems, you will need to make a vertical version of it, and hide the horizontal one for smartphones via some media queries.<\/p>\n<p>In conclusion, here is all the code from banner-start.js:<\/p>\n<pre class=\"lang:js decode:true \">\/\/ this is banner-start.js\r\nregister = document.getElementById(\"signUp\");\r\n\r\nsignUp.onmouseenter = function() {\r\n  TweenLite.to(signUp, 0.2, {scale:1.2})\r\n}\r\n\r\nsignUp.onmouseleave = function() {\r\n  TweenLite.to(signUp, 0.2, {scale:1})\r\n}\r\nvar mySplitText = new SplitText(\"#quote\", {type:\"words\"});\r\nvar tl = new TimelineMax({repeat:-1});\r\nloop =0;\r\nloopMax = 2;\r\ntl.to(\"#banner\", 1.5, {opacity:1, ease:Cubic.easeOut})\r\n.staggerFrom(mySplitText.words, 0.3, {opacity:0, scale:0.4,  ease:Back.easeOut}, 0.15)\r\n.from(\"#bouncyGreen\", 0.9,{opacity:0, y:50, ease:Elastic.easeOut, delay:0.5})\r\n.to(\"#pitchWrapper\", 1, {opacity:0, scale:0.3, y:22, ease:Back.easeIn, delay:0.5})\r\n.from(\"#callUs\", 0.5,{x:-430, ease:Cubic.easeOut, delay:0.5})\r\n.from(\"#phoneNumber\", 0.5,{x:-430, ease:Cubic.easeOut},\"-=0.4\")\r\n.from(\"#simon\", 0.5,{x:-100, ease:Cubic.easeOut},\"-=0.4\")\r\n.to(\"#potato\", 0.7,{x:330, scaleX:1, ease:Cubic.easeOut})\r\n.to(\"#theDate\", 0.5,{x:200, ease:Cubic.easeOut})\r\n.to(\"#description\", 0.5,{x:250, ease:Cubic.easeOut},\"-=0.4\")\r\n.to(\"#signUp\", 0.8,{opacity:1, scale:1, ease:Elastic.easeOut, delay:0.8})\r\n.call(loopCheck)\r\n.to(\"#banner\", 0.5,{autoAlpha:0,delay:5});\r\n\r\nfunction loopCheck(){\r\n\t\/\/console.log(\"loopCheck\")\r\n\tloop++;\r\n\tif (loop &lt; loopMax) {\r\n\t\t\/\/console.log(\"play again\")\r\n\t\ttl.play();\r\n\t} else{\r\n\t\t\/\/console.log(\"done\")\r\n\t\ttl.pause();\r\n\t}\r\n}<\/pre>\n<p>Here is all the code from banner-start.html:<\/p>\n<pre class=\"lang:xhtml decode:true \">&lt;!doctype html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=\"UTF-8\"&gt;\r\n&lt;title&gt; Ad Banner &lt;\/title&gt;\r\n&lt;link rel=\"stylesheet\" type=\"text\/css\" media=\"screen\" href=\"banner-start.css\"&gt;\r\n\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n &lt;div id=\"banner\"&gt; \r\n   &lt;div id=\"pitchWrapper\"&gt; \r\n\t     &lt;div id=\"quote\"&gt; \r\n\t     \tWe make the best Mufflers \r\n\t     &lt;\/div&gt; \r\n\t     &lt;div id=\"bouncyGreen\"&gt;\r\n\t       in Tacoma \r\n\t     &lt;\/div&gt; \r\n\t&lt;\/div&gt;&lt;!--end pitchWrapper div--&gt; \r\n\t&lt;img src=\"images\/simon2.png\" alt=\"simon\" id=\"simon\"&gt;\r\n\t&lt;h1 id=\"callUs\"&gt;Call our Cellphone:&lt;\/h1&gt;\r\n\t&lt;h2 id=\"phoneNumber\"&gt;253-234-5678&lt;\/h2&gt;\r\n\t&lt;div id=\"trapazoid2\"&gt;&lt;\/div&gt;&lt;!-- new code --&gt;\r\n\t&lt;div id=\"potato\"&gt;&lt;\/div&gt;\t&lt;!-- new code --&gt; \r\n\t&lt;h1 id=\"theDate\"&gt;September 22&lt;\/h1&gt;\r\n\t&lt;div id=\"description\"&gt;\r\n\t\tWatch us weld custom Stainless Steel mufflers for your Honda Civic  \r\n\t&lt;\/div&gt;\r\n\t&lt;a href=\"http:\/\/www.websterart.com\" id=\"signUp\"&gt;Sign Up Today!&lt;\/a&gt; \r\n   \r\n &lt;\/div&gt;&lt;!--end banner div--&gt;\r\n\r\n&lt;script src=\"js\/jquery-1.10.1.min.js\"&gt;&lt;\/script&gt;\r\n&lt;script src=\"js\/jqueryUI\/js\/jquery-ui-1.10.3.custom.min.js\"&gt;&lt;\/script&gt;\r\n&lt;script src=\"js\/TweenMax.min.js\"&gt;&lt;\/script&gt;\r\n&lt;script src=\"js\/SplitText.min.js\"&gt;&lt;\/script&gt;\r\n&lt;script src=\"js\/banner-start.js\"&gt;&lt;\/script&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>And here is the entire banner-start.css code:<\/p>\n<pre class=\"lang:css decode:true \">\/******* this is banner-start.css ********\/ \r\nbody { \r\n\tbackground-color: gray; \r\n} \r\n#banner { \r\n\theight: 90px; \r\n\twidth: 800px; \r\n\tbackground-color: #333; \r\n\tborder-radius: 15px; \r\n\tposition: relative; \r\n\topacity: 0; \r\n\tfont: 0.9em Verdana, Helvetica, sans-serif; \r\n\tcolor: white; \r\n\t\/*overflow: hidden;*\/ \r\n}\r\n#quote {\r\n\tfont:1.5em Verdana, Helvetica, sans-serif;\r\n\tfont-style: bold;\r\n\tcolor: #ccc;\r\n\tfloat: left;\r\n\tletter-spacing: 0.08em;\r\n\tmargin: 25px 0 0 10px;\r\n}\r\n\r\n#bouncyGreen {\r\n\t\r\n\tfont:3em Georgia, Times, serif;\r\n\tfloat: left;\r\n\tcolor: #0f0;\r\n\tmargin: 10px 0 0 0;\/*0ld was margin-top:-11px*\/\r\n\tpadding:0;\r\n}\r\n\r\n#simon{\r\n\tposition:absolute;\r\n\tleft:10px;\r\n\ttop:0px;\r\n\tmargin:0;\r\n\tpadding:0;\r\n\tz-index: 6;\r\n}\r\n\r\nh1#callUs{\r\n\tfont-family: Georgia, Times, serif;\r\n\tfont-size: 1.5em;\r\n\tcolor:#0f0;\r\n\tposition:absolute;\r\n\tleft: 90px;\r\n\ttop:10px;\r\n\tmargin:0;\r\n\tpadding:0;\r\n\tz-index:8;\r\n}\r\nh2#phoneNumber{\r\n\tfont-family: Georgia, Times, serif;\r\n\tfont-size: 1.0em;\r\n\r\n\tletter-spacing: 3px;\r\n\tcolor:#fff;\r\n\tposition:absolute;\r\n\tleft:90px;\r\n\ttop:45px;\r\n\tmargin:0;\r\n\tpadding:0;\r\n\tz-index:7;\t\r\n}\r\n#trapazoid2{\r\n\tbackground-color: #333;\r\n\tposition:absolute;\r\n\tleft:39px;\r\n\ttop:0;\r\n\theight:90px;\r\n\twidth:340px;\r\n\tmargin:0;\r\n\tpadding:0;\r\n\t-moz-transform: skew(-22deg, 0deg);\r\n\t-webkit-transform: skew(-22deg, 0deg);\r\n\t-o-transform: skew(-22deg, 0deg);\r\n\t-ms-transform: skew(-22deg, 0deg);\r\n\ttransform: skew(-22deg, 0deg);\r\n\topacity:1;\/* new code *\/\r\n\tz-index: 5;\r\n}\r\n#pitchWrapper{\r\nposition:absolute;\r\nleft:0;\r\ntop:0;\r\nz-index: 9;\r\n}\r\n#potato {\r\n  height: 90px;\r\n  width: 450px;\r\n  background-color: #fff;\r\n  -webkit-border-radius: 15px;\r\n  -moz-border-radius: 15px;\r\n  border-radius: 15px;\r\n  position:absolute;\r\n  left:20px;\r\n  top:0;\r\n   -ms-transform: scale(0.5,1); \/* IE 9 *\/\r\n   -webkit-transform: scale(0.5,1); \/* Safari *\/\r\n   transform: scale(0.5,1); \/* Standard syntax *\/\r\n  \/*opacity: 0;*\/\r\n  z-index: 2;\r\n}\r\nh1#theDate {\r\n\tfont-family: 'Abel', sans-serif;\r\n\tfont-size: 2em;\r\n\t\/*font-family: 'Gravitas One', cursive;\r\n\tfont-family: 'Sonsie One', cursive;*\/\r\n\tcolor:#333;\r\n\tposition:absolute;\r\n\tleft: 200px;\r\n\ttop:0px;\r\n\tmargin:0;\r\n\tpadding:0;\r\n\tz-index: 3;\r\n}\r\n\r\n#description {\r\n\tposition:absolute;\r\n\tleft:150px;\r\n\ttop:31px;\r\n\tmargin:0;\r\n\tpadding:0;\t\r\n\tcolor:#9E5111;\r\n\twidth:200px;\r\n\tz-index: 4;\r\n}\r\n#banner a#signUp {\r\n\tdisplay:block;\r\n\tposition:absolute;\r\n\ttop:15px;\r\n\tright:20px;\r\n\tcolor: rgb(230, 230, 230);\r\n\tfont-size: 1.2em;\r\n\ttext-decoration: none;\r\n\tpadding: 15px;\r\n\ttext-shadow: 0px -1px 0px rgba(30, 30, 30, 0.8);\r\n\t-webkit-border-radius: 19.864864864864863px;\r\n\t-moz-border-radius: 19.864864864864863px;\r\n\tborder-radius: 19.864864864864863px;\r\n\tbackground: rgb(176, 1, 42);\r\n\tbackground: -moz-linear-gradient(90deg, rgb(176, 1, 42) 30%, rgb(250, 20, 0) 70%);\r\n\tbackground: -webkit-linear-gradient(90deg, rgb(176, 1, 42) 30%, rgb(250, 20, 0) 70%);\r\n\tbackground: -o-linear-gradient(90deg, rgb(176, 1, 42) 30%, rgb(250, 20, 0) 70%);\r\n\tbackground: -ms-linear-gradient(90deg, rgb(176, 1, 42) 30%, rgb(250, 20, 0) 70%);\r\n\tbackground: linear-gradient(0deg, rgb(176, 1, 42) 30%, rgb(250, 20, 0) 70%);\r\n\t-webkit-box-shadow: 5px 8px 7px rgba(50, 50, 50, 0.75);\r\n\t-moz-box-shadow:    5px 8px 7px rgba(50, 50, 50, 0.75);\r\n\tbox-shadow:         5px 8px 7px rgba(50, 50, 50, 0.75);\r\n   -ms-transform: scale(0.3,0.3); \/* IE 9 *\/\r\n   -webkit-transform: scale(0.3,0.3); \/* Safari *\/\r\n   transform: scale(0.3,0.3); \/* Standard syntax *\/\r\n\/*http:\/\/css3gen.com\/button-generator\/*\/\r\n\topacity:0;\r\n\tz-index: 10;\r\n\r\n}\r\n<\/pre>\n<p>You can see both the horizontal and vertical versions of this ad running here.<\/p>\n<p><a href=\"http:\/\/websterart.com\/html\/animation-v4.php\">http:\/\/websterart.com\/html\/animation-v4.php<\/a><\/p>\n<p>I also have media queries in place that hide the horizontal and show the vertical if you arrive on a phone. If you like this tutorial, feel free to share it with your programmer friends. I wrote this one as a lesson plan for my students.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is part 2, if you are looking for part 1, it is here. Sliding Reveal Open banner-done.html and drag the playhead slider over until you see the white rectangle slide out from underneath the diagonal gray band. To get all this to work we have to configure and style half a dozen different elements [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-1602","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/pages\/1602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1602"}],"version-history":[{"count":27,"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/pages\/1602\/revisions"}],"predecessor-version":[{"id":3488,"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/pages\/1602\/revisions\/3488"}],"wp:attachment":[{"href":"https:\/\/websterart.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}