Giter Club home page Giter Club logo

Comments (3)

williamngan avatar williamngan commented on May 26, 2024

Hi @lupos, if I understand correctly, you have a canvas with pt.js in a background div, and then on top there're other DOM elements which is blocking the mouse events, correct?

I think that's the default behaviors for DOM elements. One simple way I can think of is to apply CSS "pointer-events: none" on the top element, then the mouse events should pass through and go to the background element.

Alternatively, I think you can also listen for the mouse events in a parent element (that contains both bg and the top elements), and then dispatch the mouse events into the pt.js element. Something like this:
http://stackoverflow.com/questions/6157929/how-to-simulate-a-mouse-click-using-javascript

Hope this helps. Feel free to ask if you have other questions. Cheers!

from pt.

lupos avatar lupos commented on May 26, 2024

Thanks for the reply. Yes your second suggestion will work but I was just hoping there would be a API way to just call the methods of PT directly rather than faking/passing an event. Thanks again for the help and for the great library!

from pt.

williamngan avatar williamngan commented on May 26, 2024

I see. There's no direct API yet, since onMouseAction callbacks are based on events. It's a good idea to have these also as a function call though, since dispatching events are a bit of a pain :)

from pt.

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.