Skip to content

Commit

Permalink
fix #369: pointerEvents="listener" makes uikit elements not interacta…
Browse files Browse the repository at this point in the history
…ble anymore (requires uikit >= 0.8.2 or < 0.7.0)
  • Loading branch information
bbohlender committed Nov 5, 2024
1 parent 19aaf82 commit af2e883
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 38 deletions.
26 changes: 13 additions & 13 deletions examples/uikit/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"dependencies": {
"@pmndrs/pointer-events": "workspace:^",
"@react-three/drei": "^9.108.3",
"@react-three/uikit": "^0.7.1",
"@react-three/uikit-default": "^0.7.1",
"@react-three/uikit-lucide": "^0.7.1",
"@react-three/xr": "workspace:^",
"leva": "^0.9.35"
},
"scripts": {
"dev": "vite --host"
}
}
"dependencies": {
"@pmndrs/pointer-events": "workspace:^",
"@react-three/drei": "^9.108.3",
"@react-three/uikit": "^0.8.3",
"@react-three/uikit-default": "^0.8.3",
"@react-three/uikit-lucide": "^0.8.3",
"@react-three/xr": "workspace:^",
"leva": "^0.9.35"
},
"scripts": {
"dev": "vite --host"
}
}
11 changes: 7 additions & 4 deletions packages/pointer-events/src/intersections/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,17 @@ export function intersectPointerEventTargets(
}
}

function hasObjectListeners({ _listeners, __r3f }: Object3D): boolean {
if (__r3f != null && __r3f?.eventCount > 0) {
function hasObjectListeners(object: Object3D): boolean {
if (object.ancestorsHaveListeners) {
return true
}
if (_listeners == null) {
if (object.__r3f != null && object.__r3f?.eventCount > 0) {
return true
}
if (object._listeners == null) {
return false
}
const entries = Object.entries(_listeners)
const entries = Object.entries(object._listeners)
const length = entries.length
for (let i = 0; i < length; i++) {
const entry = entries[i]
Expand Down
1 change: 1 addition & 0 deletions packages/pointer-events/src/pointer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ declare module 'three' {

intersectChildren?: boolean
interactableDescendants?: Array<Object3D>
ancestorsHaveListeners?: boolean
}
}

Expand Down
42 changes: 21 additions & 21 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit af2e883

Please sign in to comment.