aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-08-15 23:16:09 -0400
committerbobzel <zzzman@gmail.com>2024-08-15 23:16:09 -0400
commit325aa35c4bd5f57240ead2ec5f22ea9c4f19d522 (patch)
treec767fced5ef29ec216f138dad7dec2047612c51a /src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx
parent196bfbcacd554e0d5e1d437588c5719606d21025 (diff)
fixed dropping on multi col/row collections with margins
Diffstat (limited to 'src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx')
-rw-r--r--src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx94
1 files changed, 49 insertions, 45 deletions
diff --git a/src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx b/src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx
index 5125bdb6c..c6884d866 100644
--- a/src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx
+++ b/src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.tsx
@@ -17,6 +17,7 @@ import './CollectionMulticolumnView.scss';
import ResizeBar from './MulticolumnResizer';
import WidthLabel from './MulticolumnWidthLabel';
import { dropActionType } from '../../../util/DropActionTypes';
+import { SnappingManager } from '../../../util/SnappingManager';
interface WidthSpecifier {
magnitude: number;
@@ -211,15 +212,14 @@ export class CollectionMulticolumnView extends CollectionSubView() {
return Transform.Identity();
};
- @undoBatch
onInternalDrop = (e: Event, de: DragManager.DropEvent) => {
let dropInd = -1;
- if (de.complete.docDragData && this._mainCont) {
+ if (de.complete.docDragData && this._contRef.current) {
let curInd = -1;
de.complete.docDragData?.droppedDocuments.forEach(d => {
curInd = this.childDocs.indexOf(d);
});
- Array.from(this._mainCont.children).forEach((child, index) => {
+ Array.from(this._contRef.current.children).forEach((child, index) => {
const brect = child.getBoundingClientRect();
if (brect.x < de.x && brect.x + brect.width > de.x) {
if (curInd !== -1 && curInd === Math.floor(index / 2)) {
@@ -317,11 +317,11 @@ export class CollectionMulticolumnView extends CollectionSubView() {
this.childLayouts.forEach((layout, i) => {
collector.push(
// eslint-disable-next-line react/no-array-index-key
- <Tooltip title={'Tab: ' + StrCast(layout.title)} key={'wrapper' + i}>
+ <Tooltip title={'Doc: ' + StrCast(layout.title)} key={'wrapper' + i}>
<div className="document-wrapper" style={{ flexDirection: 'column', width: this.lookupPixels(layout) }}>
{this.getDisplayDoc(layout)}
{this.layoutDoc._chromeHidden ? null : (
- <Button tooltip="Remove document from header bar" icon={<FontAwesomeIcon icon="times" size="lg" />} onClick={undoable(() => this._props.removeDocument?.(layout), 'close doc')} color={SettingsManager.userColor} />
+ <Button tooltip="Remove document" icon={<FontAwesomeIcon icon="times" size="lg" />} onClick={undoable(() => this._props.removeDocument?.(layout), 'close doc')} color={SettingsManager.userColor} />
)}
<WidthLabel layout={layout} collectionDoc={this.Document} />
</div>
@@ -343,49 +343,53 @@ export class CollectionMulticolumnView extends CollectionSubView() {
return collector;
}
+ _contRef = React.createRef<HTMLDivElement>();
render() {
return (
- <div
- className="collectionMulticolumnView_contents"
- ref={this.createDashEventsTarget}
- style={{
- width: `calc(100% - ${2 * NumCast(this.Document._xMargin)}px)`,
- height: `calc(100% - ${2 * NumCast(this.Document._yMargin)}px)`,
- marginLeft: NumCast(this.Document._xMargin),
- marginRight: NumCast(this.Document._xMargin),
- marginTop: NumCast(this.Document._yMargin),
- marginBottom: NumCast(this.Document._yMargin),
- }}>
- {this.contents}
- {!this._startIndex ? null : (
- <Tooltip title="scroll back">
- <div
- style={{ position: 'absolute', bottom: 0, left: 0, background: SettingsManager.userVariantColor }}
- onClick={action(() => {
- this._startIndex = Math.min(this.childLayoutPairs.length - 1, this._startIndex + this.maxShown);
- })}>
- <Button
- tooltip="Scroll back"
- icon={<FontAwesomeIcon icon="chevron-left" size="lg" />}
+ <div className="collectionMulticolumnView_drop" ref={this.createDashEventsTarget}>
+ <div
+ className="collectionMulticolumnView_contents"
+ ref={this._contRef}
+ style={{
+ pointerEvents: this._props.isContentActive() && SnappingManager.IsDragging ? 'all' : this._props.pointerEvents?.(),
+ width: `calc(100% - ${2 * NumCast(this.Document._xMargin)}px)`,
+ height: `calc(100% - ${2 * NumCast(this.Document._yMargin)}px)`,
+ marginLeft: NumCast(this.Document._xMargin),
+ marginRight: NumCast(this.Document._xMargin),
+ marginTop: NumCast(this.Document._yMargin),
+ marginBottom: NumCast(this.Document._yMargin),
+ }}>
+ {this.contents}
+ {!this._startIndex ? null : (
+ <Tooltip title="scroll back">
+ <div
+ style={{ position: 'absolute', bottom: 0, left: 0, background: SettingsManager.userVariantColor }}
onClick={action(() => {
- this._startIndex = Math.max(0, this._startIndex - this.maxShown);
- })}
- color={SettingsManager.userColor}
- />
- </div>
- </Tooltip>
- )}
- {this._startIndex > this.childLayoutPairs.length - 1 || !this.maxShown ? null : (
- <Tooltip title="scroll forward">
- <div
- style={{ position: 'absolute', bottom: 0, right: 0, background: SettingsManager.userVariantColor }}
- onClick={action(() => {
- this._startIndex = Math.min(this.childLayoutPairs.length - 1, this._startIndex + this.maxShown);
- })}>
- <IconButton icon={<FaChevronRight />} color={SettingsManager.userColor} />
- </div>
- </Tooltip>
- )}
+ this._startIndex = Math.min(this.childLayoutPairs.length - 1, this._startIndex + this.maxShown);
+ })}>
+ <Button
+ tooltip="Scroll back"
+ icon={<FontAwesomeIcon icon="chevron-left" size="lg" />}
+ onClick={action(() => {
+ this._startIndex = Math.max(0, this._startIndex - this.maxShown);
+ })}
+ color={SettingsManager.userColor}
+ />
+ </div>
+ </Tooltip>
+ )}
+ {this._startIndex > this.childLayoutPairs.length - 1 || !this.maxShown ? null : (
+ <Tooltip title="scroll forward">
+ <div
+ style={{ position: 'absolute', bottom: 0, right: 0, background: SettingsManager.userVariantColor }}
+ onClick={action(() => {
+ this._startIndex = Math.min(this.childLayoutPairs.length - 1, this._startIndex + this.maxShown);
+ })}>
+ <IconButton icon={<FaChevronRight />} color={SettingsManager.userColor} />
+ </div>
+ </Tooltip>
+ )}
+ </div>
</div>
);
}