Sie sind nicht angemeldet.

1

Sonntag, 31. Januar 2021, 23:00

repeat tween only after done with previous tween action

Hi,

I want to tween hotspot scales 10% onover and -10% onout with following style:

Quellcode

1
2
3
  <style ...
onover.addevent="tween(scale,get(hotspot[scale].add(0.1%)));"
onout.addevent="tween(scale,get(hotspot[scale].add(-0.1%)));"/>

Now if someone quickly hovers a hs again while the first onover-action is still tweening, the scale may add onover 0.1% again before adding onout -0.1%.
I tried with ",,,WAIT" but I seem to place it wrong.

Maybe someone can point me to the correct or a better solution?

Thanks an kind regards,
loki

2

Sonntag, 31. Januar 2021, 23:18

get(hotspot[scale].add(0.1%))
--> uhmm... this syntax is not valid at all... *squint*

tween(scale, calc(scale * 1.1));
--> would be possible but won't work, because the onover/onout actions will be called also while they are still tweening and the scale didn't reach its endvalues, yet. so using such a calculation your scale will be way off track over time.

why the 0.1% value anyway? you want 10% ?

possible approach using a backup value for the scale
onover="if(scale_bak===null,copy(scale_bak,scale));tween(scale,calc(scale_bak*1.1));"
onout="tween(scale,get(scale_bak));"

Dieser Beitrag wurde bereits 7 mal editiert, zuletzt von »indexofrefraction« (31. Januar 2021, 23:44)


3

Montag, 1. Februar 2021, 00:21

Hi,

thanks for your help. It works like a charm *smile*
I added "set(scale_bak, null);" after the "onout" action to keep various scales for different scaled hotspots.

Sorry for the bad syntax earlier, it probably was a caching mistake. Before that, I used an old code example of Klaus (which also has the problem of tween-time not ending before new tween possible):

Quellcode

1
2
onover.addevent="add(newscale,scale,0.1); tween(scale,get(newscale));"
onout.addevent="add(newscale,scale,-0.1); tween(scale,get(newscale));"

Why 0.1%? It was a coding-noob-mistake:
Instead of "0.1", in the beginning I tried with "10%", but it made the hotspot huge.
I didn't understand, that "10%" got interpreted as "10", so I just tried a way lower value "0.1%", which worked fine for me (because 0.1 looked good). Understanding now that it's not percent even though it was written there, it makes much more sense.

This was a satisfying lecture. *thumbsup*

Working code:

Quellcode

1
2
onover.addevent="if(scale_back===null,copy(scale_back,scale));tween(scale,calc(scale_back * 1.1));"
onout.addevent="tween(scale,calc(scale_back)); set(scale_back, null);"

4

Montag, 1. Februar 2021, 09:22

the reason of this here is to backup the scale only once, on the first call:
if(scale_back===null,copy(scale_back,scale));

now with your set(scale_back, null); you make the backup obsolete.
on the next onover the backup will be made again, and probably not with the same as the initial scale was
with this the scale will go bananas very fast.

without clearing the backup the tween targets will always stay the same
onover="if(scale_back===null,copy(scale_back,scale));tween(scale,calc(scale_back * 1.1));"
onout="tween(scale,calc(scale_back));"


;-)

Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »indexofrefraction« (1. Februar 2021, 17:20)


5

Sonntag, 7. Februar 2021, 23:15

Hmmm I understand. The "bananas" are still there when using "set(scale_back, null);".

Without "set(scale_back, null);" I get weird behaviour still.



It feels like the first hotspot I click gets set as default size.

For example:
I go from p1 to p2 using hs1 scale 0.7. onover 0.7*1.1, onout 0.7 - nice.
Then, in p2 there is hs2 scale 0.6 and hs3 scale 0.8 - both grow/shrink to 0.7*1.1 onover and scale back to 0.7 onout.

*confused*



6

Montag, 8. Februar 2021, 12:44

Hi,

maybe try something like this:

Quellcode

1
2
3
4
5
6
<style ...
   initialscale="1"
   onloaded.addevent="copy(initialscale, scale);"
   onover.addevent="tween(scale, calc(initialscale * 1.1) );"
   onout.addevent="tween(scale, get(initialscale) );"
   />


That will define a initialscale variable at the hotspot, copy the 'scale' to it once the hotspot is loaded and then uses that as reference scale for the onover/onout events.

Best regards,
Klaus

7

Dienstag, 23. März 2021, 11:40

Thank you Klaus,

the above example works.

Happy to learn about that attribute and curious, since I cannot find any more info about it.
"initialscale" is not to be confused with the viewport "initial-scale" attribute, right?

Best,
loki

8

Dienstag, 23. März 2021, 12:29

this is not a built in attribute and has nothing to do with viewpport

initialscale is just a backup of the (hotspots) scale

onloaded --> make backup of scale
onover --> tween to backup * 1.1
onout --> tween to backup

9

Dienstag, 23. März 2021, 22:23

Ahhh!

Thanks for additional explanation, index!

Now the penny dropped and I understand that the scale value is copied to the newly defined "initialscale" variable with its self-chosen name.
This is great and I'm looking forward to use the (probably really basic) variables-as-backup-defining in the future.

Best,
loki