Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better click-area for signs #29

Closed
akamud opened this issue Oct 24, 2020 · 3 comments
Closed

Provide better click-area for signs #29

akamud opened this issue Oct 24, 2020 · 3 comments

Comments

@akamud
Copy link

akamud commented Oct 24, 2020

We're trying to implement a feature on our app that depends on the user clicking on the symbols (planets, cusps, signs). We do this using this code:

svg g[id*="astrology-radix-planets-"],
svg g[id*="astrology-radix-cusps-"],
svg g[id*="astrology-radix-signs-"] {
    pointer-events: all;
    cursor: pointer;
}

It works, but some symbols don't have a bounding box, which makes the click very difficult.
You can see this behaviour here (I've zoomed in so it is easier to notice the problem):

astrochart

Notice the Scorpio symbol has a "bounding box", so it is clickable through all its area. The same isn't true for the Libra sign, with the way it is drawn, I have to click exactly on its stroke paths, which is very difficult with no zoom, as you can imagine. This makes clicking very erratic.

Workaround

As a workaround, we've added a transparent rect for all the signs, like this:

	function createRectForClick(x, y, width, height) {
		var rect = document.createElementNS(context.root.namespaceURI, 'rect')
		rect.setAttribute('x', x - astrology.SIGNS_STROKE)
		rect.setAttribute('y', y - astrology.SIGNS_STROKE)
		rect.setAttribute('width', width)
		rect.setAttribute('height', height)
		rect.setAttribute('fill', 'transparent')
		return rect
	}

This makes the whole sign area clickable again.

Would you be interested in fixing this behaviour? I could open a PR.

@afucher
Copy link
Collaborator

afucher commented Oct 27, 2020

Hey @akamud,

thanks for bringing this suggestion! Feel free to implement this behaviour.

Can you make this behaviour behind a toogle? So the developer can decide to use or not. This could be implemented using the settings options.

@afucher
Copy link
Collaborator

afucher commented Mar 2, 2021

Hi @akamud ,

We are moving this repo to https://github.com/AstroDraw/AstroChart.
All the issues will be handled there, if you want you can open this issue there. If not, in the next weeks I'll open it there for you 😄

@afucher
Copy link
Collaborator

afucher commented Aug 7, 2021

Issue moved to the new repo: AstroDraw/AstroChart#6

@afucher afucher closed this as completed Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants