Fix merge conflicts

pull/21833/head
Dariusz Niemczyk 2021-08-06 16:29:23 +02:00
parent 4328083ea7
commit cba87f433b
No known key found for this signature in database
GPG Key ID: 28DFE7164F497CB6
3 changed files with 28 additions and 7 deletions

View File

@ -184,11 +184,12 @@ export default class CallPreview extends React.Component<IProps, IState> {
className="mx_CallPreview" className="mx_CallPreview"
draggable={pipMode} draggable={pipMode}
> >
{ (onMouseDownOnHeader) => <CallView { (onMouseDownOnHeader, onResizeHandler) => <CallView
onMouseDownOnHeader={onMouseDownOnHeader} onMouseDownOnHeader={onMouseDownOnHeader}
call={this.state.primaryCall} call={this.state.primaryCall}
secondaryCall={this.state.secondaryCall} secondaryCall={this.state.secondaryCall}
pipMode={pipMode} pipMode={pipMode}
onResize={onResize}
/> } /> }
</PictureInPictureDragger> </PictureInPictureDragger>

View File

@ -55,7 +55,7 @@ interface IProps {
// a callback which is called when the content in the CallView changes // a callback which is called when the content in the CallView changes
// in a way that is likely to cause a resize. // in a way that is likely to cause a resize.
onResize?: any; onResize?: () => void;
// Whether this call view is for picture-in-picture mode // Whether this call view is for picture-in-picture mode
// otherwise, it's the larger call view when viewing the room the call is in. // otherwise, it's the larger call view when viewing the room the call is in.

View File

@ -33,9 +33,14 @@ const PADDING = {
right: 8, right: 8,
}; };
interface IChildrenOptions {
onStartMoving: (event: React.MouseEvent<Element, MouseEvent>) => void;
onResize: (event: React.MouseEvent<Element, MouseEvent>) => void;
}
interface IProps { interface IProps {
className?: string; className?: string;
children: (startMovingEventHandler: (event: React.MouseEvent<Element, MouseEvent>) => void) => React.ReactNode; children: ({ onStartMoving, onResize }: IChildrenOptions) => React.ReactNode;
draggable: boolean; draggable: boolean;
} }
@ -74,13 +79,13 @@ export class PictureInPictureDragger extends React.Component<IProps, IState> {
public componentDidMount() { public componentDidMount() {
document.addEventListener("mousemove", this.onMoving); document.addEventListener("mousemove", this.onMoving);
document.addEventListener("mouseup", this.onEndMoving); document.addEventListener("mouseup", this.onEndMoving);
window.addEventListener("resize", this.snap); window.addEventListener("resize", this.onResize);
} }
public componentWillUnmount() { public componentWillUnmount() {
document.removeEventListener("mousemove", this.onMoving); document.removeEventListener("mousemove", this.onMoving);
document.removeEventListener("mouseup", this.onEndMoving); document.removeEventListener("mouseup", this.onEndMoving);
window.removeEventListener("resize", this.snap); window.removeEventListener("resize", this.onResize);
} }
private animationCallback = () => { private animationCallback = () => {
@ -126,7 +131,11 @@ export class PictureInPictureDragger extends React.Component<IProps, IState> {
} }
} }
private snap = () => { private onResize = (): void => {
this.snap(false);
};
private snap = (animate = false) => {
const translationX = this.desiredTranslationX; const translationX = this.desiredTranslationX;
const translationY = this.desiredTranslationY; const translationY = this.desiredTranslationY;
// We subtract the PiP size from the window size in order to calculate // We subtract the PiP size from the window size in order to calculate
@ -158,6 +167,17 @@ export class PictureInPictureDragger extends React.Component<IProps, IState> {
// We start animating here because we want the PiP to move when we're // We start animating here because we want the PiP to move when we're
// resizing the window // resizing the window
this.scheduledUpdate.mark(); this.scheduledUpdate.mark();
if (animate) {
// We start animating here because we want the PiP to move when we're
// resizing the window
this.scheduledUpdate.mark();
} else {
this.setState({
translationX: this.desiredTranslationX,
translationY: this.desiredTranslationY,
});
}
}; };
private onStartMoving = (event: React.MouseEvent | MouseEvent) => { private onStartMoving = (event: React.MouseEvent | MouseEvent) => {
@ -181,7 +201,7 @@ export class PictureInPictureDragger extends React.Component<IProps, IState> {
private onEndMoving = () => { private onEndMoving = () => {
this.moving = false; this.moving = false;
this.snap(); this.snap(true);
}; };
public render() { public render() {