Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. <div>
  2. <span></span>
  3. <span></span>
  4. </div>
  5.  
  6. body {text-align: center;}
  7.  
  8. div {border: 2px solid #000; display: inline-block; padding: 5px 20px; vertical-align: middle;}
  9.  
  10. span:first-of-type:after {content: "|"; margin: 0 10px;}
  11.  
  12. $(document).ready(function (e) {
  13. showViewportSize();
  14. });
  15.  
  16. $(window).resize(function (e) {
  17. showViewportSize();
  18. });
  19.  
  20. function showViewportSize() {
  21. var the_width = $(window).width();
  22. var the_height = $(window).height();
  23. $('span:first-of-type').text(the_width);
  24. $('span:last-of-type').text(the_height);
  25. }
  26.  
  27. $('#start').on('click', function(){
  28.  
  29. var windowheight = $(window).height();
  30. var windowwidth = $(window).width();
  31. $('.putmehere1').html('height: ' +
  32. windowheight +
  33. 'width: ' +
  34. windowwidth);
  35.  
  36. var startwidth = 0;
  37. var endwidth = windowwidth;
  38. var startheight = 0;
  39. var endheight = windowheight;
  40. var timer;
  41. var timer2;
  42.  
  43. timedCount();
  44. timedCount2();
  45.  
  46.  
  47. function timedCount()
  48. {
  49. startwidth = startwidth + 1;
  50. timer = setTimeout(function(){timedCount()}, 20);
  51. $('.putwidth').html(startwidth);
  52. if (startwidth == endwidth)
  53. {
  54. clearTimeout(timer);
  55. startwidth = endwidth;
  56. }
  57. }
  58.  
  59. function timedCount2()
  60. {
  61. startheight = startheight + 1;
  62. timer2 = setTimeout(function(){timedCount2()}, 20);
  63. $('.putheight').html(startheight);
  64. if (startheight == endheight)
  65. {
  66. clearTimeout(timer2);
  67. startheight = endheight;
  68. }
  69. }
  70.  
  71. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement