Jump to content

Search In
  • More options...
Find results that contain...
Find results in...


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
  • Location
    Louisville, KY

devindavid's Achievements



  1. Eh, I think I'm going to abandon this approach, I finally got it to work (kind of), but my math formula isn't producing the desired effect-http://codepen.io/devindavid/pen/YwjNeV I just ended up timing everything manually, which ended up being good because I had better control over things- http://codepen.io/devindavid/pen/rxKJLK But, Here's what I did to dynamically update the repeating tween duration using an onRepeat callback and the .duration() method. Everything in the getDuration() function can be replaced with any variables and functions to calculate the value. function myTimedFunction() { var timerDuration = 10000; var d = new Date(); var t = d.getTime(); var tween = new TweenMax.to(".element", 3, { x:"1200px", ease:Power0.easeInOut, onRepeat:getDuration, repeat:-1 }); function getDuration() { var elapsedTime = function(){ var e = Math.floor(Date.now()) - t; return e; }; var remainingTime = function(){ var r = timerDuration - elapsedTime(); return r; }; var durationSpeed = function() { var j = remainingTime() / timerDuration; var k = Math.pow(j, 3) * (elapsedTime() / 2); var l = ((k + 300)/1000); return l; }; tween.duration(durationSpeed()); }; }; window.onload = myTimedFunction(); setInterval(function() { myTimedFunction(); }, 10000);
  2. So, I made this motorcycle where the spinning wheels speed up and slow down using basic easing and specifying the number of rotations for each duration- http://codepen.io/devindavid/pen/rxKJLK/ I'm trying to put it on a road that moves at a speed corresponding to the speed of the wheels. So basically, dynamically changing the tween duration for an infinitely repeating tween. The road- http://codepen.io/devindavid/pen/YwjNeV I've figured out the math for each 10 second duration (i'd change the acceleration and deceleration of the wheels to 10s), but I'm pretty new to Javascript, and can't seem to get it to work if i try to use a variable as the tween duration value. But, the math does seem to work in a JS console... The value for the road's tween duration comes out between apx. 0.1s to 2s, and it works if I just use a number. Is there a way to write the code differently in order to pass the function into a TimelineMax where it runs the function for the specified duration? Ultimately the function will be added to the motorcycle's existing timeline. Thanks!