diff options
author | aidahosa1 <aisosa_idahosa@brown.edu> | 2024-03-18 13:39:34 -0400 |
---|---|---|
committer | aidahosa1 <aisosa_idahosa@brown.edu> | 2024-03-19 16:27:37 -0400 |
commit | 2d4abcd15acec7d07be5ed608d15b39f32a8fb44 (patch) | |
tree | 7719e68d87ad716ba7a27f457ef1cff77cf7aba2 /src/client/documents/Documents.ts | |
parent | cec94dd9ced4f9af74189a4cffa0b113b5a0c4f1 (diff) |
the lack of pushing is astounding actually
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r-- | src/client/documents/Documents.ts | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 1d7c73306..be382afe3 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -1218,6 +1218,15 @@ export namespace Docs { ); } + export function CardDeckDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) { + return InstanceFromProto( + Prototypes.get(DocumentType.COL), + new List(documents), + { backgroundColor: 'transparent', dropAction: dropActionType.move, _forceActive: true, _freeform_noZoom: true, _freeform_noAutoPan: true, ...options, _type_collection: CollectionViewType.Card }, + id + ); + } + export function LinearDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) { return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Linear }, id); } @@ -1864,6 +1873,44 @@ export namespace DocUtils { return newCollection; } } + + export function spreadCards(docList: Doc[], x: number = 0, y: number = 0, spreadAngle: number = 30, radius: number = 100, create: boolean = true) { + const totalCards = docList.length; + const halfSpreadAngle = spreadAngle * 0.5; + const angleStep = spreadAngle / (totalCards - 1); + + runInAction(() => { + docList.forEach((d, i) => { + DocUtils.iconify(d); + const angle = (-halfSpreadAngle + angleStep * i) * (Math.PI / 180); // Convert degrees to radians + d.x = x + Math.cos(angle) * radius; + d.y = y + Math.sin(angle) * radius; + d.rotation = angle; // Assuming 'd.rotation' sets the rotation, adjust accordingly + d._timecodeToShow = undefined; + }); + }); + + if (create) { + const newCollection = Docs.Create.CardDeckDocument(docList, { + title: 'card-spread', + _freeform_noZoom: true, + x: x - radius, + y: y - radius, + _width: radius * 2, + _height: radius * 2, + dragWhenActive: true, + _layout_fitWidth: false + }); + // Adjust position based on the collection's dimensions if needed + newCollection.x = NumCast(newCollection.x) + NumCast(newCollection._width) / 2 - radius; + newCollection.y = NumCast(newCollection.y) + NumCast(newCollection._height) / 2 - radius; + newCollection._width = newCollection._height = radius * 2; + return newCollection; + } + } + + + export function makeIntoPortal(doc: Doc, layoutDoc: Doc, allLinks: Doc[]) { const portalLink = allLinks.find(d => d.link_anchor_1 === doc && d.link_relationship === 'portal to:portal from'); if (!portalLink) { |