Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. window.requestAnimFrame = function(){
  2. return (
  3. window.requestAnimationFrame ||
  4. window.webkitRequestAnimationFrame ||
  5. window.mozRequestAnimationFrame ||
  6. window.oRequestAnimationFrame ||
  7. window.msRequestAnimationFrame ||
  8. function(/* function */ callback){
  9. window.setTimeout(callback, 1000 / 60);
  10. }
  11. );
  12. }();
  13.  
  14. function animationSequence(elem, ind) {
  15. this.ind = ind;
  16. this.elem = elem;
  17. this.distance = 450;
  18. this.duration = 900;
  19. this.increment = 0;
  20. this.start = Math.abs(this.ind)*450;
  21. var requestId = requestAnimFrame(this.animate);
  22. this.move();
  23.  
  24. this.move = function() {
  25. this.elem.style.left = this.start - this.increment + "px";
  26. }
  27. this.animate = function() {
  28. var self = this;
  29. this.move();
  30. this.increment += 5;
  31. if (this.increment >= 450) {
  32. if (this.ind == 0) { console.log("true"); this.elem.style.left = "1350px" }
  33. cancelAnimFrame(requestId);
  34. }
  35. }
  36. // this.animate();
  37. }
  38.  
  39. var requestId = requestAnimFrame(this.animate.bind(this));
  40.  
  41. let requestId = requestAnimFrame(() => { this.animate(); });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement