Advertisement
Guest User

transitionend

a guest
Oct 23rd, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.39 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>javascript 0</title>
  7. <style type="text/css">
  8. p {
  9.     transition:1s;
  10. }
  11.  
  12. .changed0 {
  13.     background-color:red;
  14.     color:green;
  15.     font-size:2em;
  16. }
  17. .changed1 {
  18.     background-color:green;
  19.     color:red;
  20.     font-size:4em;
  21. }
  22. .changed2 {
  23.     background-color:blue;
  24.     color:yellow;
  25.     font-size:8em;
  26. }
  27. .changed3 {
  28.     background-color:magenta;
  29.     color:cyan;
  30.     font-size:2em;
  31. }
  32.  
  33. .wow {
  34.     background-color:red;
  35.     padding:2em;
  36.     color:cyan;
  37.     font-size:10em;
  38.     line-height:10em;
  39. }
  40. </style>
  41. </head>
  42. <body>
  43.     <p id="one" class="changed0">lorem</p>
  44.     <p id="two">ipsum</p>
  45. <script>
  46. var counter = 0;
  47. var ourLovelyP = document.querySelector("#one");
  48.  
  49. var doSomething = function () {
  50.     ourLovelyP.classList.remove("changed" + counter);
  51.     counter = counter + 1;
  52.     if (counter > 3) {
  53.         // counter = 0;
  54.         ourLovelyP.addEventListener("transitionend", doWowStuff, false);
  55.     }
  56.     document.title = "(" + counter +")";
  57.     ourLovelyP.classList.add("changed" + counter);
  58. };
  59. document.addEventListener("click", doSomething, false);
  60.  
  61. var doWowStuff = function () {
  62.     ourLovelyP.classList.remove("changed" + counter);
  63.     ourLovelyP.classList.add("wow");
  64.     document.title = Math.random();
  65.     ourLovelyP.removeEventListener("transitionend", doWowStuff);
  66. };
  67.  
  68.  
  69. </script>
  70. </body>
  71. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement