Author Topic: Transition.StartNavigation ?  (Read 3490 times)

Oomek

  • Administrator
  • Sr. Member
  • *****
  • Posts: 311
  • Radek Dutkiewicz
    • View Profile
    • github.com/oomek
Transition.StartNavigation ?
« on: February 25, 2017, 06:26:29 PM »
I'm looking for a way to play an animation (game list slide-in) but just once when the key/joy is pressed and held.
The event Transition.EndNavigation works fine for slide-out, but I cannot find any equivalent event to do the fade-in.
Is it possible to do with the current api or I would need some new Transition.StartNavigation event to do that?

Oomek

  • Administrator
  • Sr. Member
  • *****
  • Posts: 311
  • Radek Dutkiewicz
    • View Profile
    • github.com/oomek
Re: Transition.StartNavigation ?
« Reply #1 on: February 25, 2017, 07:20:36 PM »
I could do it like this:

Code: [Select]
local move_gameListBoxFadeIn = {
    onStart = function( anim ) { if ( listbox_hidden == true) { time = 250; listbox_hidden = false; }
    else  { time = 0; } },
    wait = true,
    when = Transition.ToNewSelection, property = "x", start = flx*0.822, end = flx*0.51, tween = Tween.Expo
}
local move_gameListBoxFadeOut = {
    onStop = function( anim ) { listbox_hidden = true },
    when = Transition.ToNewSelection, property = "x", start = flx*0.51, end = flx*0.822, time = 250, delay=2000, tween = Tween.Expo
}

but the AM is shouting at me for using wait = true. Is there any other way of doing it?

edit: The main problem here is that onStart is not beeing called if the animation is triggered again before the first run finishes.
« Last Edit: February 25, 2017, 07:38:15 PM by Oomek »

Oomek

  • Administrator
  • Sr. Member
  • *****
  • Posts: 311
  • Radek Dutkiewicz
    • View Profile
    • github.com/oomek
Re: Transition.StartNavigation ?
« Reply #2 on: February 26, 2017, 11:00:44 AM »
Anyone? Plz? I'm stuck with my theme... :(

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Transition.StartNavigation ?
« Reply #3 on: February 26, 2017, 03:51:03 PM »
AM is not shouting at you about using wait, the animate module is.. wait is ok, as long as you don't mind not being able to use key presses during that time..

Transition.StartLayout and/or Transition.ToNewList is probably what you want:
https://github.com/mickelson/attract/blob/master/Layouts.md#add_transition_callback

You may also want to check var for those as well in your if statement, depending on your use case.

if you do need to use onStart, you can set restart for the animation to false in the options - this will prevent it from restarting an animation if it is already running... check out some of the options in PropertyAnimation:

https://raw.githubusercontent.com/liquid8d/attract-extra/master/modules/animate/property.nut

Oomek

  • Administrator
  • Sr. Member
  • *****
  • Posts: 311
  • Radek Dutkiewicz
    • View Profile
    • github.com/oomek
Re: Transition.StartNavigation ?
« Reply #4 on: February 26, 2017, 06:24:08 PM »
Thank you, "restart = false" did the trick.