Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div>
- <span></span>
- <span></span>
- </div>
- body {text-align: center;}
- div {border: 2px solid #000; display: inline-block; padding: 5px 20px; vertical-align: middle;}
- span:first-of-type:after {content: "|"; margin: 0 10px;}
- $(document).ready(function (e) {
- showViewportSize();
- });
- $(window).resize(function (e) {
- showViewportSize();
- });
- function showViewportSize() {
- var the_width = $(window).width();
- var the_height = $(window).height();
- $('span:first-of-type').text(the_width);
- $('span:last-of-type').text(the_height);
- }
- $('#start').on('click', function(){
- var windowheight = $(window).height();
- var windowwidth = $(window).width();
- $('.putmehere1').html('height: ' +
- windowheight +
- 'width: ' +
- windowwidth);
- var startwidth = 0;
- var endwidth = windowwidth;
- var startheight = 0;
- var endheight = windowheight;
- var timer;
- var timer2;
- timedCount();
- timedCount2();
- function timedCount()
- {
- startwidth = startwidth + 1;
- timer = setTimeout(function(){timedCount()}, 20);
- $('.putwidth').html(startwidth);
- if (startwidth == endwidth)
- {
- clearTimeout(timer);
- startwidth = endwidth;
- }
- }
- function timedCount2()
- {
- startheight = startheight + 1;
- timer2 = setTimeout(function(){timedCount2()}, 20);
- $('.putheight').html(startheight);
- if (startheight == endheight)
- {
- clearTimeout(timer2);
- startheight = endheight;
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement