runemadsen / rune.js

A JavaScript library for programming graphic design systems with SVG
http://runemadsen.github.io/rune.js
MIT License
654 stars 35 forks source link

mouse events does not work #42

Open ChristerNilsson opened 6 years ago

duncangeere commented 4 years ago

I'm also finding that mouse events aren't working.

ChristerNilsson commented 4 years ago

As this project unfortunately seems to be a dead parrot, I have switched to SVG and Raphael.

runemadsen commented 4 years ago

@ChristerNilsson I don't consider this project dead, as I'm using it continuously in my own work. However, I don't have time to work for free on every feature that someone requests in a one-line issue. Which mouse events are you speaking of? Are they global or on specific shapes? Please post a code example to help with debugging. Since this is an open source project, I would be more than happy to receive pull requests if you want to add functionality to rune.js or solve an existing bug.

duncangeere commented 4 years ago

@runemadsen I'm glad the project is still alive! Thanks for your time creating it - I've used it for a lot of my pen plotter generative art.

Here's a very simple example that doesn't work for me, running the latest versions of Firefox and OSX.

var r = new Rune({
    container: "body",
    width: 500,
    height: 500
});

r.on("click", function () {r.circle(Math.random() * r.width, Math.random() * r.height, 50, 50)})

r.play();

Using the browser tools, I can see the SVG, I can see there's an event listener attached to it, but clicking the SVG does not place a circle as expected.

Perhaps I'm using the r.on() function in the wrong way? My Javascript skills aren't up to the task of tracking down and fixing the error, but any guidance would be appreciated.

ChristerNilsson commented 4 years ago

This works:

r.el.addEventListener('click', function (mouse) {   
    r.circle(mouse.x, mouse.y, 50, 50)
})