Skip to content

Commit

Permalink
fix: elements instantly disappearing instead of fading out on mouse l…
Browse files Browse the repository at this point in the history
…eave

ref #685
  • Loading branch information
tomasklaen committed Oct 9, 2023
1 parent 484c553 commit c5de082
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions scripts/uosc/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -320,30 +320,36 @@ cursor = {
cursor.y = y == INFINITY and y or y + 0.5

if old_x ~= cursor.x or old_y ~= cursor.y then
Elements:update_proximities()

if cursor.x == INFINITY or cursor.y == INFINITY then
cursor.hidden = true
cursor.history:clear()

-- Slowly fadeout elements that are currently visible
for _, element_name in ipairs({'timeline', 'volume', 'top_bar'}) do
local element = Elements[element_name]
if element and element.proximity > 0 then
element:tween_property('forced_visibility', element:get_visibility(), 0, function()
element.forced_visibility = nil
end)
if element then
local visibility = element:get_visibility()
if visibility > 0 then
element:tween_property('forced_visibility', visibility, 0, function()
element.forced_visibility = nil
end)
end
end
end

Elements:update_proximities()
Elements:trigger('global_mouse_leave')
elseif cursor.hidden then
cursor.hidden = false
cursor.history:clear()
Elements:trigger('global_mouse_enter')
else
-- Update history
cursor.history:insert({x = cursor.x, y = cursor.y, time = mp.get_time()})
Elements:update_proximities()

if cursor.hidden then
cursor.hidden = false
cursor.history:clear()
Elements:trigger('global_mouse_enter')
else
-- Update history
cursor.history:insert({x = cursor.x, y = cursor.y, time = mp.get_time()})
end
end

Elements:proximity_trigger('mouse_move')
Expand Down

0 comments on commit c5de082

Please sign in to comment.