mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 15:06:02 +01:00
Revert "refactor(web/menu): radial menu onHover"
This reverts commit f20e3a288f.
This commit is contained in:
@@ -2,7 +2,6 @@ local isOpen = false
|
|||||||
local menus = {}
|
local menus = {}
|
||||||
local menuItems = {}
|
local menuItems = {}
|
||||||
local currentRadial = nil
|
local currentRadial = nil
|
||||||
local currentHover = nil
|
|
||||||
|
|
||||||
|
|
||||||
function lib.registerRadial(radial)
|
function lib.registerRadial(radial)
|
||||||
@@ -25,19 +24,9 @@ local function showRadial(id)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function getRadialItem(index)
|
|
||||||
return not currentRadial and menuItems[index + 1] or currentRadial.items[index + 1]
|
|
||||||
end
|
|
||||||
|
|
||||||
function lib.hideRadial()
|
function lib.hideRadial()
|
||||||
if not isOpen then return end
|
if not isOpen then return end
|
||||||
|
|
||||||
if currentHover then
|
|
||||||
local item = getRadialItem(currentHover)
|
|
||||||
item.onHover(false)
|
|
||||||
currentHover = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'openRadialMenu',
|
action = 'openRadialMenu',
|
||||||
data = false
|
data = false
|
||||||
@@ -82,18 +71,9 @@ function lib.removeRadialItem(id)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RegisterNUICallback('radialHover', function(data, cb)
|
|
||||||
cb(1)
|
|
||||||
local item = getRadialItem(data.index)
|
|
||||||
|
|
||||||
if not item.onHover then return end
|
|
||||||
item.onHover(data.entered)
|
|
||||||
currentHover = data.entered and data.index
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNUICallback('radialClick', function(index, cb)
|
RegisterNUICallback('radialClick', function(index, cb)
|
||||||
cb(1)
|
cb(1)
|
||||||
local item = getRadialItem(index)
|
local item = not currentRadial and menuItems[index + 1] or currentRadial.items[index + 1]
|
||||||
|
|
||||||
if item.onSelect then item.onSelect() end
|
if item.onSelect then item.onSelect() end
|
||||||
if item.menu then return showRadial(item.menu) end
|
if item.menu then return showRadial(item.menu) end
|
||||||
|
|||||||
@@ -97,8 +97,6 @@ const RadialMenu: React.FC = () => {
|
|||||||
transform={`rotate(-${index * pieAngle} 175 175)`}
|
transform={`rotate(-${index * pieAngle} 175 175)`}
|
||||||
className={classes.sector}
|
className={classes.sector}
|
||||||
onClick={() => fetchNui('radialClick', index)}
|
onClick={() => fetchNui('radialClick', index)}
|
||||||
onMouseEnter={() => fetchNui('radialHover', { index, entered: true })}
|
|
||||||
onMouseLeave={() => fetchNui('radialHover', { index, entered: false })}
|
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
d={`M175.01,175.01 l175,0 A175.01,175.01 0 0,0 ${175 + 175 * Math.cos(-degToRad(pieAngle))}, ${
|
d={`M175.01,175.01 l175,0 A175.01,175.01 0 0,0 ${175 + 175 * Math.cos(-degToRad(pieAngle))}, ${
|
||||||
|
|||||||
Reference in New Issue
Block a user