Fusion icon indicating copy to clipboard operation
Fusion copied to clipboard

Tween freezing when goal and info compute from the same state

Open Zyrakia opened this issue 3 years ago • 2 comments

It seems that Tween stops working if both the goalState and tweenInfo are states and have the same dependency. I may be missing something, or maybe this is just an antipattern but in me eyes it should work?

Repro:

local isVisible = Value(false)

local info = Computed(function()
  local direction = if isVisible:get() then Enum.EasingDirection.Out else Enum.EasingDirection.In
  return TweenInfo.new(0.6, Enum.EasingStyle.Back, direction)
end)

local size = Computed(function()
  return if isVisible:get() then UDim2.fromScale(1, 1) else UDim2.fromScale(0.25, 0.25)
end)

local tween = Tween(size, info)

-- affects the size and info separately, but not the tween
isVisible:set(true)

Zyrakia avatar May 09 '22 22:05 Zyrakia

Haven't tested this yet, but off the top of my head I think I know why this may be - the Tween's :update() function only runs once, but also is coded in such a fashion as to only expect one of the two states to have changed.

#145 would help with this I think.

dphfox avatar May 10 '22 14:05 dphfox

Related to #205

dphfox avatar Feb 01 '23 01:02 dphfox