mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-16 03:31:31 +03:00
Always keep the PiP CallView on the screen
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
f93ff1c8ae
commit
d8d380c74d
1 changed files with 23 additions and 2 deletions
|
@ -209,8 +209,29 @@ export default class CallPreview extends React.Component<IProps, IState> {
|
|||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
this.lastX = event.pageX - this.initX;
|
||||
this.lastY = event.pageY - this.initY;
|
||||
const width = this.callViewWrapper.current.clientWidth;
|
||||
const height = this.callViewWrapper.current.clientHeight;
|
||||
|
||||
const precalculatedLastX = event.pageX - this.initX;
|
||||
const precalculatedLastY = event.pageY - this.initY;
|
||||
|
||||
// Avoid overflow on the x axis
|
||||
if (precalculatedLastX + width >= window.innerWidth) {
|
||||
this.lastX = window.innerWidth - width;
|
||||
} else if (precalculatedLastX <= 0) {
|
||||
this.lastX = 0;
|
||||
} else {
|
||||
this.lastX = precalculatedLastX;
|
||||
}
|
||||
|
||||
// Avoid overflow on the y axis
|
||||
if (precalculatedLastY + height >= window.innerHeight) {
|
||||
this.lastY = window.innerHeight - height;
|
||||
} else if (precalculatedLastY <= 0) {
|
||||
this.lastY = 0;
|
||||
} else {
|
||||
this.lastY = precalculatedLastY;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
translationX: this.lastX,
|
||||
|
|
Loading…
Reference in a new issue