aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/OverlayView.tsx
diff options
context:
space:
mode:
authorSophie Zhang <sophie_zhang@brown.edu>2023-09-26 16:49:43 -0400
committerSophie Zhang <sophie_zhang@brown.edu>2023-09-26 16:49:43 -0400
commitf2958fd4d7dab5369c9e68c5d8f3b50332391aac (patch)
tree633e77c196ad4c8c51fb7244e4af22c88168e10d /src/client/views/OverlayView.tsx
parentaa3dc83bdd723db2597dc36fe09ae288ce3641da (diff)
parent78edc744c77e378728d033001331737df0b2f393 (diff)
Merge branch 'master' into sophie-ai-images
Diffstat (limited to 'src/client/views/OverlayView.tsx')
-rw-r--r--src/client/views/OverlayView.tsx16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/client/views/OverlayView.tsx b/src/client/views/OverlayView.tsx
index 62aa4d1d4..c174befc0 100644
--- a/src/client/views/OverlayView.tsx
+++ b/src/client/views/OverlayView.tsx
@@ -1,4 +1,3 @@
-
import { action, computed, observable } from 'mobx';
import { observer } from 'mobx-react';
import { computedFn } from 'mobx-utils';
@@ -17,6 +16,7 @@ import { LightboxView } from './LightboxView';
import { DocumentView, DocumentViewInternal } from './nodes/DocumentView';
import './OverlayView.scss';
import { DefaultStyleProvider } from './StyleProvider';
+const _global = (window /* browser */ || global) /* node */ as any;
export type OverlayDisposer = () => void;
@@ -116,6 +116,20 @@ export class OverlayView extends React.Component {
super(props);
if (!OverlayView.Instance) {
OverlayView.Instance = this;
+ new _global.ResizeObserver(
+ action((entries: any) => {
+ for (const entry of entries) {
+ DocListCast(Doc.MyOverlayDocs?.data).forEach(doc => {
+ if (NumCast(doc.overlayX) > entry.contentRect.width - 10) {
+ doc.overlayX = entry.contentRect.width - 10;
+ }
+ if (NumCast(doc.overlayY) > entry.contentRect.height - 10) {
+ doc.overlayY = entry.contentRect.height - 10;
+ }
+ });
+ }
+ })
+ ).observe(window.document.body);
}
}