Need "setElementProperty" method has callback [solved]


(Charles) #1

Hi,

I have a problem,when i did “setElementProperty”,I want to do other things. but that’s not real continuous.

for example

  hypeDocument.setElementProperty(element, propertyName, value, optionalDuration, optionalTimingFunctionName);
  aftersetdo();

and correct method is

hypeDocument.setElementProperty(element, propertyName, value, optionalDuration, optionalTimingFunctionName,function(){
 //to do
});

(Charles) #2

I modify HYPE-596 file ,and it’s works fine


(Loves Hype) #3

I like the idea and it is common in popular tweening engines. I also was missing a multi porperty solution so I made the extension setElementProperties (plural):

This extension could just be modifies to use a time out to trigger an onCompleteHandler.

BTW modifying the runtime is not a good idea as you will be reapplying your “patches” on every update of Hype and potentially every export of your project (depending how you set it up).


(Charles) #4

Thx 4 your reply ,yours work is awesome and of a great inspiration to me.

yeap ,extension&plugs is a good way. I know inject runtime file seems rude :joy:

I’ll check other plugs libraries


(Jonathan Deutsch) #5

From a Hype feature standpoint I’m curious what would be your expectation of this callback if the animation was interrupted by another timeline? Possible options:

  • callback is called at the duration time no matter what
  • callback is called immediately when interrupted
  • callback is not called

(Charles) #6

callbak when set animation is complete.


(Jonathan Deutsch) #7

There are circumstances where it may not be able to complete, so I’m curious about your expectations in those situations.


(Loves Hype) #9

I’d go for 3 (not called). If your goal is to fire in progression and the intended animation is paused or interrupted so should the progression. I’d also look at Greensocks tweenlite or tweenmax and how they go about it.


(Jonathan Deutsch) #10

Thanks!

My recollection from doing so a few weeks ago is greensock will chain commands and won’t interrupt, so it isn’t an issue for how they do animations.


(Mark Hunte) #11

Am I wrong in thinking if you introduced this as a feature you would be able to have a set of result codes to check against which would include codes for such interruptions and allow you to handle them depending on the result code?.


(Jonathan Deutsch) #12

This could be a possibility; the standard for cancelable actions (like a network request) is to provide a success and error callback, but I’d also like to keep things simple.


(Loves Hype) #13

In TweeMax and TweenLite the onComplete never fires if you pause or kill a tween.
See https://greensock.com/get-started-js#callbacks


(Jonathan Deutsch) #14

Cool, I missed seeing that, thanks!


(Loves Hype) #15

I was still thinking about this. Using a complete handler is a valid way to implement the initial temporal cascade and is done so in TweenLite. But Hype has already the built in concept of a timeline that might also be a solution, given one could create a virtual timeline and add actions to it through code. One then could use all the usual and already known operations on it like play, stop and jumps to specific time indeces. That logic is already implemented in the runtime.

The setProperty-Call-Chain discussed here also could be added via an extension but also introduces a complete new stack of things to worry about and keep track of. Guess it would be the easier fallback if Hype doesn’t expose a proper virtual timeline API, though.


(Jonathan Deutsch) #16

In fact, setElementProperty does make a timeline under-the-hood, so the most basic implementation of a callback is adding a timeline action at the end. This is what brought up my question of behavior; this timeline action would currently be called even if the property became owned by a different timeline, and I wasn’t sure this was in line with expectations. It would be interesting to expose the timeline identifier for control along with giving the ability to add animations/timeline actions to it.