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 #6

Closed
afucher opened this issue Aug 7, 2021 · 1 comment · Fixed by #8
Closed

Provide better click-area for signs #6

afucher opened this issue Aug 7, 2021 · 1 comment · Fixed by #8
Labels
enhancement New feature or request

Comments

@afucher
Copy link
Contributor

afucher commented Aug 7, 2021

Issue moved from old repo created by @akamud

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 afucher added the enhancement New feature or request label Aug 7, 2021
@afucher
Copy link
Contributor Author

afucher commented Aug 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant