diff options
author | bobzel <zzzman@gmail.com> | 2024-05-03 10:23:46 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-05-03 10:23:46 -0400 |
commit | 723c8b33ade753764d1d02b130c189fb65e20425 (patch) | |
tree | e278304fdace45a2c38562e72a3ccd2e8e91b759 /src/client/views/collections/CollectionCarouselView.tsx | |
parent | f410a7b314dd78244e18c9c52140b67b37ab0c87 (diff) | |
parent | 2caf7b7bb80b663b6ba585f88cdbd2d725f8505e (diff) |
Merge branch 'master' into nathan-starter
Diffstat (limited to 'src/client/views/collections/CollectionCarouselView.tsx')
-rw-r--r-- | src/client/views/collections/CollectionCarouselView.tsx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/client/views/collections/CollectionCarouselView.tsx b/src/client/views/collections/CollectionCarouselView.tsx index dae16bafb..9c370bfbb 100644 --- a/src/client/views/collections/CollectionCarouselView.tsx +++ b/src/client/views/collections/CollectionCarouselView.tsx @@ -12,6 +12,7 @@ import { FieldViewProps } from '../nodes/FieldView'; import { FormattedTextBox } from '../nodes/formattedText/FormattedTextBox'; import './CollectionCarouselView.scss'; import { CollectionSubView } from './CollectionSubView'; +import { DocumentType } from '../../documents/DocumentTypes'; @observer export class CollectionCarouselView extends CollectionSubView() { @@ -33,13 +34,17 @@ export class CollectionCarouselView extends CollectionSubView() { } }; + @computed get carouselItems() { + return this.childLayoutPairs.filter(pair => pair.layout.type !== DocumentType.LINK); + } + advance = (e: React.MouseEvent) => { e.stopPropagation(); - this.layoutDoc._carousel_index = (NumCast(this.layoutDoc._carousel_index) + 1) % this.childLayoutPairs.length; + this.layoutDoc._carousel_index = (NumCast(this.layoutDoc._carousel_index) + 1) % this.carouselItems.length; }; goback = (e: React.MouseEvent) => { e.stopPropagation(); - this.layoutDoc._carousel_index = (NumCast(this.layoutDoc._carousel_index) - 1 + this.childLayoutPairs.length) % this.childLayoutPairs.length; + this.layoutDoc._carousel_index = (NumCast(this.layoutDoc._carousel_index) - 1 + this.carouselItems.length) % this.carouselItems.length; }; captionStyleProvider = (doc: Doc | undefined, captionProps: Opt<FieldViewProps>, property: string): any => { // first look for properties on the document in the carousel, then fallback to properties on the container @@ -55,7 +60,7 @@ export class CollectionCarouselView extends CollectionSubView() { captionWidth = () => this._props.PanelWidth() - 2 * this.marginX; @computed get content() { const index = NumCast(this.layoutDoc._carousel_index); - const curDoc = this.childLayoutPairs?.[index]; + const curDoc = this.carouselItems?.[index]; const captionProps = { ...this._props, NativeScaling: returnOne, PanelWidth: this.captionWidth, fieldKey: 'caption', setHeight: undefined, setContentView: undefined }; const carouselShowsCaptions = StrCast(this.layoutDoc._layout_showCaption); return !(curDoc?.layout instanceof Doc) ? null : ( |