You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, November 7th 2017, 9:53pm

using built-in tweener

hello,

I see that krpano has some tweening code in it, but no straightforward way to access it? it seems it only works on variables that were created in krpano, and also only calls krpano actions on update / complete events, so I have to write this:

Source code

1
2
3
4
5
6
krpano.actions[ 'ourTransitionAction'.toLowerCase () ] = function () { ... }
...
krpano.set ('ourTransitionProgress', 0);
krpano.actions.tween ('ourTransitionProgress', 1,
	0.6, // = transition time, seconds
	krpano.tweentypes.easeoutquad, null, 'ourTransitionAction');


which is ugly. But, since the code is already there, I want to avoid using another tweening lib. Is there cleaner way to access this functionality?

Thanks.

2

Monday, November 13th 2017, 11:07pm

Hi,

right - the tweening works only on krpano variables, but the 'updatecall' and 'donecall' parameters can be also JS-functions.

Btw - the 'tweentype' parameter is a string, e.g. 'easeoutquad' - krpano.tweentypes.easeoutquad would be wrong.

Here a tween function that could be used to tween the property of an JS object:

Source code

1
2
3
4
5
6
7
8
9
10
11
function mytween(obj, propname, destvalue, time, tweentype, updatecall, donecall)
{
  var varname = "mytweens." + propname;
  krpano.set(varname, obj[propname]);
  function update()
  {
    obj[propname] = krpano.get(varname);
    if (updatecall != null) updatecall();
  }
  krpano.actions.tween(varname, destvalue, time, tweentype, donecall, update);
}

It first creates a krpano variable with the current value and then tweens that variable.
In the update function the object property will be set to the tweened value and optonally the updatecall callback function be called.
And when done the donecall callback function.

Best regards,
Klaus