How to position in the mouse click?
See original GitHub issueI finally managed to position using pure popper a div inside a SVG. I wish to do the same with tippy
I’m trying the following approach which does not work:
select(e: MouseEvent) {
const ref = {
getBoundingClientRect() {
return {
width: e.layerY,
height: e.layerX,
top: e.layerY,
left: e.layerX,
right: 0,
bottom: 0
}
},
clientHeight: 100,
clientWidth: 100
}
tippy('.line', {
target: 'polyline',
trigger: 'click',
arrow: true
}, ref);
}
This worked with popper:
select(e: MouseEvent) {
const ref = {
getBoundingClientRect: () => ({
top: e.layerY,
right: e.layerX,
bottom: e.layerY,
left: e.layerX,
width: 0,
height: 0,
}),
clientWidth: 0,
clientHeight: 0,
}
const pop = document.getElementById('template'); // the popup element
this.popper = new Popper(ref, pop);
}
What am I missing?
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Getting the Mouse Click Position in JavaScript | kirupa.com
You want the X and Y position based on the top-left (aka the starting position) corner of your document. It is this value...
Read more >javascript get x and y coordinates on mouse click
Creates (undefined) variables for the X and Y coordinates of the mouse; Attaches a function to the "mousemove" event (which will set those ......
Read more >JavaScript: Get Mouse Coordinates on Mouse Click - YouTube
JavaScript Keyboard Events: Difference between Keydown, Keyup and Keypress Events · Move Element to Mouse Click Position · getBoundingClientRect() ...
Read more >Mouse and Keyboard Controls
Ctrl - right mouse button click: Zoom down around the clicked point. Left mouse button drag: Holding the left button down and moving...
Read more >Position of mouse pointer does not match screen coordinates ...
Open control panel > Hardware & Sound. · Click on Mouse. · In mouse properties, click on pointer option tab. · Decrease the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yeah, you need to use the object as the actual reference itself.
But I see that you want to use the line as the reference for tippy to handle listeners for, but want a custom position where they clicked… that’s a really valid use case that hasn’t been added yet 😢 .
This was fixed in Dec 2018 🤔