Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. let drawSVG = function() {
  2. let paths = document.getElementsByClassName("cls-1");
  3. for (let i = 0; i < paths.length; i++) {
  4. let path = paths[i];
  5. let length = path.getTotalLength();
  6. // Clear any previous transition
  7. path.style.transition = path.style.WebkitTransition =
  8. 'none';
  9. // Set up the starting positions
  10. path.style.strokeDasharray = length + ' ' + length;
  11. path.style.strokeDashoffset = length;
  12. // Trigger a layout so styles are calculated & the browser
  13. // picks up the starting position before animating
  14. path.getBoundingClientRect();
  15. // Define our transition
  16. path.style.transition = path.style.WebkitTransition =
  17. 'stroke-dashoffset 10s ease-in-out';
  18. // Go!
  19. path.style.strokeDashoffset = '0';
  20. }
  21. }
  22.  
  23. drawSVG();
  24. /* From Modernizr */
  25. function whichTransitionEvent() {
  26. var t;
  27. var el = document.createElement('fakeelement');
  28. var transitions = {
  29. 'transition': 'transitionend',
  30. 'OTransition': 'oTransitionEnd',
  31. 'MozTransition': 'transitionend',
  32. 'WebkitTransition': 'webkitTransitionEnd'
  33. }
  34.  
  35. for (t in transitions) {
  36. if (el.style[t] !== undefined) {
  37. return transitions[t];
  38. }
  39. }
  40. }
  41. /* Listen for a transition! */
  42. var transitionEvent = whichTransitionEvent();
  43. var transitionDone = false;
  44. transitionEvent && document.body.addEventListener(transitionEvent,
  45. function() {
  46. transitionDone = true;
  47. document.body.className = "pointer";
  48. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement