Codepen
http://codepen.io/tconroy/pen/RPzxgz
Basic setting:
I am trying to create a page structured with two columns inside a centered container, with a maximum of 1600 pixels wide.
The left column contains the contents of the page. The right column contains the ad unit (say, 640x480 pixels wide).
At 768px or a lower breakpoint, your library must have 2 columns stacked (for content to be on top and ads below).
Problem
When the page loads, there should be a 400x400 pixel canvas element containing a white circle in the center of the screen (the absolute center is vertical and horizontal).
The circle moves to the position immediately behind the contents of the left column.
After that, the circle should βexpandβ to fill the entire user viewport without closing the content or causing the appearance of scroll bars.
As shown in my script below, I got the initial loop / movement animation, but I ran into problems trying to figure out part of the extension. I need a circle so that it grows / expands until it covers the entire viewport, but the entire text content / ad unit should not be obscured and the scroll bars will not appear as a result of the animation.
I am incredibly unfamiliar with the canvas, so if someone could give me a hand without breaking the original animation, that would be very grateful. :)
http://codepen.io/tconroy/pen/RPzxgz
HTML:
<div class="container"> <div class="navigation row"> <h1 style="float:right;"><a href="#">Continue</a></h1> </div> <div class="content row"> <div class="circle-wrap"> <canvas class="circle" width="400" height="400"></canvas> <div class="template-output"> <h1 class="title"> <span class="upper">Title TopLine</span> <span class="lower">Title Bottom</span> </h1> <div class="body"> <p class="description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorum distinctio nesciunt nostrum magni neque. Iusto et delectus iure distinctio cupiditate, a sint doloremque ratione saepe sunt quisquam assumenda, eaque velit?</p> <p class="byline">- Author Name</p> </div> </div> </div> </div> <div class="ads row"> <figure class="ad"> <figcaption>Advertisement</figcaption> <div id="welcome"></div> </figure> </div> </div> </div>
CSS
* { box-sizing: border-box; padding: 0; margin: 0; } html, body { width: 100%; height: 100%; background: gray; overflow: hidden; } .container { width: 100%; height: 100%; max-width: 1600px; margin: 0 auto; outline: 1px solid black; } .row { width: 50%; height: 100%; float: left; display: block; } .row.content { border: 1px solid blue; } .row.ads { border: 1px solid red; } .row.navigation { width: 100%; height: auto; } @media screen and (max-width: 768px) { .row { width: 100%; height: auto; } } .ad { display: table; margin: 0 auto; } .ad figcaption { text-align: center; margin: 0 auto; } .ad #welcome { outline: 1px solid black; background: darkgray; width: 640px; height: 480px; margin: 0 auto; } .content { min-height: 400px; } .content .template-output { width: 400px; position: relative; } .content .template-output .title { font-size: 4em; } .content .template-output .title span { display: block; text-transform: uppercase; } .content .template-output .title .upper { text-align: left; } .content .template-output .title .lower { text-align: right; } .content .template-output .body { position: relative; } .content .circle-wrap { position: relative; width: 100%; height: 100%; margin: 0 auto; } .content .circle-wrap .circle { width: 400px; height: 400px; outline: 1px solid black; position: absolute; left: 0; top: 0; transform: translate(0%, 0%); } .content .circle-2 { position: absolute; width: 100%; height: 100%; left: 0; top: 0; }
JAVASCRIPT (included: jQuery and GSAP TweenMax libraries)
(function () { var tl = new TimelineMax(); var $canvas = $('.circle'), $canvas_wrap = $('.circle-wrap'), canvas = $canvas[0], context = canvas.getContext('2d'), canvas_width = canvas.width, canvas_height = canvas.height; context.globalCompositeOperation='destination-over'; draw(context); var canvas_opts = { 'center-to-destination': { xPercent: -50, yPercent: -50, top: '50%', left: '100%', delay: 1.5 } }; tl.from(canvas, 1, canvas_opts['center-to-destination']); })();