@@ -146,7 +146,7 @@ export default class CallPreview extends React.Component<IProps, IState> {
146
146
this . roomStoreToken = RoomViewStore . addListener ( this . onRoomViewStoreUpdate ) ;
147
147
document . addEventListener ( "mousemove" , this . onMoving ) ;
148
148
document . addEventListener ( "mouseup" , this . onEndMoving ) ;
149
- window . addEventListener ( "resize" , this . snap ) ;
149
+ window . addEventListener ( "resize" , this . onResize ) ;
150
150
this . dispatcherRef = dis . register ( this . onAction ) ;
151
151
MatrixClientPeg . get ( ) . on ( CallEvent . RemoteHoldUnhold , this . onCallRemoteHold ) ;
152
152
}
@@ -156,14 +156,18 @@ export default class CallPreview extends React.Component<IProps, IState> {
156
156
MatrixClientPeg . get ( ) . removeListener ( CallEvent . RemoteHoldUnhold , this . onCallRemoteHold ) ;
157
157
document . removeEventListener ( "mousemove" , this . onMoving ) ;
158
158
document . removeEventListener ( "mouseup" , this . onEndMoving ) ;
159
- window . removeEventListener ( "resize" , this . snap ) ;
159
+ window . removeEventListener ( "resize" , this . onResize ) ;
160
160
if ( this . roomStoreToken ) {
161
161
this . roomStoreToken . remove ( ) ;
162
162
}
163
163
dis . unregister ( this . dispatcherRef ) ;
164
164
SettingsStore . unwatchSetting ( this . settingsWatcherRef ) ;
165
165
}
166
166
167
+ private onResize = ( ) : void => {
168
+ this . snap ( false ) ;
169
+ } ;
170
+
167
171
private animationCallback = ( ) => {
168
172
// If the PiP isn't being dragged and there is only a tiny difference in
169
173
// the desiredTranslation and translation, quit the animationCallback
@@ -207,7 +211,7 @@ export default class CallPreview extends React.Component<IProps, IState> {
207
211
}
208
212
}
209
213
210
- private snap = ( ) => {
214
+ private snap ( animate ?: boolean ) : void {
211
215
const translationX = this . desiredTranslationX ;
212
216
const translationY = this . desiredTranslationY ;
213
217
// We subtract the PiP size from the window size in order to calculate
@@ -236,10 +240,17 @@ export default class CallPreview extends React.Component<IProps, IState> {
236
240
this . desiredTranslationY = PADDING . top ;
237
241
}
238
242
239
- // We start animating here because we want the PiP to move when we're
240
- // resizing the window
241
- this . scheduledUpdate . mark ( ) ;
242
- } ;
243
+ if ( animate ) {
244
+ // We start animating here because we want the PiP to move when we're
245
+ // resizing the window
246
+ this . scheduledUpdate . mark ( ) ;
247
+ } else {
248
+ this . setState ( {
249
+ translationX : this . desiredTranslationX ,
250
+ translationY : this . desiredTranslationY ,
251
+ } ) ;
252
+ }
253
+ }
243
254
244
255
private onRoomViewStoreUpdate = ( ) => {
245
256
if ( RoomViewStore . getRoomId ( ) === this . state . roomId ) return ;
@@ -310,7 +321,7 @@ export default class CallPreview extends React.Component<IProps, IState> {
310
321
311
322
private onEndMoving = ( ) => {
312
323
this . moving = false ;
313
- this . snap ( ) ;
324
+ this . snap ( true ) ;
314
325
} ;
315
326
316
327
public render ( ) {
@@ -333,6 +344,7 @@ export default class CallPreview extends React.Component<IProps, IState> {
333
344
secondaryCall = { this . state . secondaryCall }
334
345
pipMode = { true }
335
346
onMouseDownOnHeader = { this . onStartMoving }
347
+ onResize = { this . onResize }
336
348
/>
337
349
</ div >
338
350
) ;
0 commit comments