Comments (6)
I've also had trouble with the default Draggable
implementation, when the mouse gets out of the canvas (below or above the viewport) while dragging the object & the mouse buton is released.
I'd love to have the default example updated to fix this issue.
from hex-engine.
Hi! Thanks for looking into this!
Could you explain this bit further?
Something like this won't work because we attach the listener to the box.
As an aside... something I have been meaning to do is make LowLevelMouse use only one mouse event listener per Canvas, by leveraging the "StorageFor
" pattern found elsewhere in the codebase. If things consuming LowLevelMouse were all being called from the same mouse event listener (set up in the root), would it resolve the issue you're running into?
from hex-engine.
So, this code will works.
mouse.onUp(onUp);
mouse.onLeave(onUp);
but if the mouse is moved too fast and exits the red box, then it will suddenly have its gravity back. The code says about Mouse.mouseLeave: "called whenever the mouse cursor exits the configured Entity's bounds". And apparently the entity is the box at this point (and that makes sense).
For your idea I will think about it. The listener should be in root, but somehow must tell all the root draggable children to restore their isStatic and reset their isDragging. I'm not sure it's possible.
from hex-engine.
So I came up with something that seem to fix this.
I am not quite sure about the naming and how to test the generated site, I just copied what I have on my local.
Would you please have a look if I go the right way with your code?
from hex-engine.
As an aside... something I have been meaning to do is make LowLevelMouse use only one mouse event listener per Canvas, by leveraging the "StorageFor" pattern found elsewhere in the codebase. If things consuming LowLevelMouse were all being called from the same mouse event listener (set up in the root), would it resolve the issue you're running into?
I am not sure to understand everything about the StorageFor pattern :)
But from what I see in "StorageForWindowSize" I guess you would still wrap the in/out detection with some logic as it is done in the Mouse component, and will cause the same problem.
You either need to provide access to lower level things (mouseover, mouseout), or find a nice abstraction like "IsMouseInsideViewport" or something.
from hex-engine.
Fixed in c7be799
from hex-engine.
Related Issues (20)
- Inspector improvements HOT 2
- Add raycasting functions HOT 4
- Display a spinner when creating a new project HOT 1
- Performance with many physics objects HOT 4
- Animated GIF component
- Issue with Mouse.insideBounds & rotated geometry HOT 3
- API Proposal: useContext HOT 10
- Typing errors when starting/building create-hex-engine-game project HOT 5
- Blocking call to window.localStorage
- Add a script to build a desktop game. HOT 1
- Do not include any inspector code in production builds HOT 1
- Document "StorageFor" pattern
- Image should support "repeat" pattern HOT 3
- Systems HOT 7
- Tiled: Support embedded tilesets in maps HOT 1
- Error in webpack when building in CI HOT 1
- Ogmo decals and entities are rendered with the wrong origin offset
- Ogmo 3.4.0 support
- ERR_OSSL_EVP_UNSUPPORTED with node 18
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hex-engine.