Use epsilon to compare values in `move_towards`
This commit is contained in:
parent
be5f94e913
commit
3d879286a4
|
@ -25,7 +25,8 @@ function View:move_towards(t, k, dest, rate)
|
||||||
return self:move_towards(self, t, k, dest, rate)
|
return self:move_towards(self, t, k, dest, rate)
|
||||||
end
|
end
|
||||||
local val = t[k]
|
local val = t[k]
|
||||||
if not config.transitions or math.abs(val - dest) < 0.5 then
|
local diff = math.abs(val - dest)
|
||||||
|
if not config.transitions or diff < 0.5 then
|
||||||
t[k] = dest
|
t[k] = dest
|
||||||
else
|
else
|
||||||
rate = rate or 0.5
|
rate = rate or 0.5
|
||||||
|
@ -35,7 +36,7 @@ function View:move_towards(t, k, dest, rate)
|
||||||
end
|
end
|
||||||
t[k] = common.lerp(val, dest, rate)
|
t[k] = common.lerp(val, dest, rate)
|
||||||
end
|
end
|
||||||
if val ~= dest then
|
if diff > 1e-8 then
|
||||||
core.redraw = true
|
core.redraw = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue