is there any way to animate gadget movement ?

Just starting out? Need help? Post your questions and find answers here.
skinkairewalker
Posts: 120
Joined: Tue Jun 14, 2016 7:17 pm

is there any way to animate gadget movement ?

Post 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 >

Image
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: is there any way to animate gadget movement ?

Post 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);
skinkairewalker
Posts: 120
Joined: Tue Jun 14, 2016 7:17 pm

Re: is there any way to animate gadget movement ?

Post 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?
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: is there any way to animate gadget movement ?

Post 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}
skinkairewalker
Posts: 120
Joined: Tue Jun 14, 2016 7:17 pm

Re: is there any way to animate gadget movement ?

Post by skinkairewalker »

wow, amazing.
living and learning !!
thank you so much !!!!
Post Reply