How to dynamically position popper with caret offset?
See original GitHub issueWhat is the expected behavior?
I am trying to build an auto suggestion or mention plugin using popper.
- Popper position should update on caret position updates e.g on textarea.
- If popper reaches view port boundary position should also update.
What went wrong?
Right i can update the position but i cannot do the view port boundary
this.popper = new Popper(this.ref, this.popEl, {
removeOnDestroy: true,
modifiers: {
preventOverflow: {
enabled: true,
},
updatePosition: {
enabled: true,
order: 800,
fn: data => {
console.log(this.props.coords);
return {
...data,
styles: {
...data.styles,
top: this.props.coords.top + 20,
left: this.props.coords.left - 25,
},
};
},
},
showPopper: {
enabled: true,
order: 850,
fn: data => {
return {
...data,
styles: {
...data.styles,
display: this.props.isOpen ? 'block' : 'none',
},
};
},
},
},
});
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to dynamically position popper with caret offset? #519
I am trying to build an auto suggestion or mention plugin using popper. Popper position should update on caret position updates e.g on...
Read more >How to update the x/y position of a popper.js element?
appendChild(div) // get the marker position, this is the caret position top and left relative to the input const { offsetLeft: spanX, ...
Read more >Everything I Know About Positioning Poppers (Tooltips ...
If the popper is not positioned relative to the viewport, we need to consider its offsetParent when measuring the reference element.
Read more >Popper (v2.×)
Slower development cycle: When pure CSS is used to position popper elements, the lack of dynamic positioning means they must be carefully placed...
Read more >How to Build a Dynamically Positioned Popover with Popper ...
Go to the blog post: https://www.elegantthemes.com/blog/di... The popper.js library is a powerful positioning engine for tooltips and ...
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 FreeTop 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
Top GitHub Comments
I think the API is the same, you can adapt my code.
This should help https://codepen.io/FezVrasta/pen/YEVrGP