Page 1 of 1
is there any way to animate gadget movement ?
Posted: Sat Jun 12, 2021 3:31 am
by skinkairewalker
Hello everyone, I would like to know if there is any way to animate the movement of gadgets between a specific X,Y point to another specific X,Y point
like this >
Re: is there any way to animate gadget movement ?
Posted: Sat Jun 12, 2021 1:00 pm
by Peter
You can use jQuery.animate():
Code: Select all
Enumeration
#Window
#Card
EndEnumeration
Procedure CardEvent()
Static newX = 10
Protected GID = GadgetID(#Card)
If newX = 10
newX = WindowWidth(#Window) - GadgetWidth(#Card) - 10
Else
newX = 10
EndIf
! $(v_gid.div).animate({ left: so_cardevent$v_newx + "px" }, 1000 ); // -> https://api.jquery.com/animate/
EndProcedure
OpenWindow(#Window, 0, 0, 1000, 200, "", #PB_Window_ScreenCentered)
ContainerGadget(#Card, 10, 10, 180, 180) : CloseGadgetList()
SetGadgetColor(#Card, #PB_Gadget_BackColor, #Red)
GID = GadgetID(#Card)
! $(v_gid.div).click(f_cardevent);
Re: is there any way to animate gadget movement ?
Posted: Sat Jun 12, 2021 3:22 pm
by skinkairewalker
Awesome !!
thanks you very much
Peter
Peter wrote: ↑Sat Jun 12, 2021 1:00 pm
Code: Select all
! $(v_gid.div).animate({ left: so_cardevent$v_newx + "px" }, 1000 ); // -> https://api.jquery.com/animate/
but on this line > what means " so_cardevent " ? it shouldn't be f_cardevent, because cardevent() is a procedure?
Re: is there any way to animate gadget movement ?
Posted: Sat Jun 12, 2021 3:38 pm
by Peter
skinkairewalker wrote: ↑Sat Jun 12, 2021 3:22 pmbut on this line > what means " so_cardevent " ? it shouldn't be f_cardevent, because cardevent() is a procedure?
so_cardevent$v_newx is the 'internal' JavaScript-Name of the static newX -Variable
-> so_[SB-Procedurename]$v_[SB-StaticVariablename}
Re: is there any way to animate gadget movement ?
Posted: Sat Jun 12, 2021 4:32 pm
by skinkairewalker
wow, amazing.
living and learning !!
thank you so much !!!!