iron-overlay-behavior
iron-overlay-behavior copied to clipboard
Incorrect positioning of overlay using `horizontalOffset` and `verticalOffset` when body overflows viewport.
Version
v2.3.4 of iron-overlay-behaviour.
Description
Using iron-overlay-behaviour to implement a right click (context) menu. The menu is to be displayed at the position the user right clicked. The position is being incorrectly calculated when the body overflows the viewport and the position of the right click is such that the menu would extend beyond the right edge or bottom edge of the viewport.
Expected outcome
The menu should be displayed at or as close as possible to the position specified by horizontalOffset
and verticalOffset
.
Actual outcome
The menu is displayed near the top or left of the viewport well away from where the click occurred.
Live Demo
Steps to reproduce
bower install
polymer serve --open
Size browser window so red box overflows the viewport (ie less than 800x800 pixels). Right click near left top, overlay shows in correct position. Right click towards the right or bottom edges, the overlay shows in an incorrect position.
Browsers Affected
- [x] Chrome
- [x] Firefox
- [x] Safari 14
(not tested others)
Screen Recording of the behaviour
https://user-images.githubusercontent.com/99895/132032488-6d7e2fe4-d623-4a19-b627-a680d1e5c03b.mov