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

Add coordinates to click and dblclick events for SVG and root elements #532

Merged
merged 1 commit into from
Nov 10, 2016

Conversation

frankier
Copy link

@frankier frankier commented Nov 9, 2016

No description provided.

@cmontella
Copy link
Contributor

cmontella commented Nov 9, 2016

It looks like you're saving two sets of coordinates? For example, the given code produces the following output when an SVG is clicked:

store the coordinate of the last clicked SVG

search @event
  [#click x y]

search 
  last-click = [#last-click]

commit
  last-click.x := x
  last-click.y := y

Create a default #last-click

search
  not([#last-click])

commit
  [#last-click x: 0 y: 0]

Display the last-clicked coordinate in a view

search
  [#last-click x y]

bind @view
  [#value | value: "({{x}}, {{y}})"]

Output:

(1132, 135)
(1132, 38.33333206176758)
(24.66666603088379, 135)
(24.66666603088379, 38.33333206176758)

@frankier
Copy link
Author

Yeah. I can see how that's not so convenient from that example. The way I made it at the moment is SVG elements set it to the position in their local coordinate space and the root element sends clientX and clientY. All I actually want/need myself is the SVG coordinates but I thought document coordinates might be useful to someone too. Perhaps they should be relative to the application container however?

One way I could make your specific example work is by their names to svgx, svgy and clientx, clienty or similar. There's still the possibility of a similar issue arising in the presence of nested SVGs. The best solution is to specify the element you're interested in.

Thoughts?

@cmontella cmontella merged commit 84db538 into witheve:master Nov 10, 2016
@cmontella
Copy link
Contributor

Okay, I understand your intention now. I think maybe this is okay then. Will merge.

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

Successfully merging this pull request may close these issues.

3 participants