Git Product home page Git Product logo

Comments (6)

coyotte508 avatar coyotte508 commented on May 22, 2024 2

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.

suchipi avatar suchipi commented on May 22, 2024

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.

sixty-nine avatar sixty-nine commented on May 22, 2024

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.

sixty-nine avatar sixty-nine commented on May 22, 2024

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.

sixty-nine avatar sixty-nine commented on May 22, 2024

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.

suchipi avatar suchipi commented on May 22, 2024

Fixed in c7be799

from hex-engine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.