From 6339ce36664b008c4274dc51fc2e7851b9dabf89 Mon Sep 17 00:00:00 2001 From: madelinegr Date: Mon, 10 Jun 2019 14:03:33 -0400 Subject: Next And Back Fixed For groups --- .../views/presentationview/PresentationView.tsx | 49 ++++++++++++++-------- 1 file changed, 32 insertions(+), 17 deletions(-) (limited to 'src/client/views/presentationview') diff --git a/src/client/views/presentationview/PresentationView.tsx b/src/client/views/presentationview/PresentationView.tsx index 93c084dfd..8d1be6af1 100644 --- a/src/client/views/presentationview/PresentationView.tsx +++ b/src/client/views/presentationview/PresentationView.tsx @@ -91,18 +91,18 @@ export class PresentationView extends React.Component { next = async () => { const current = NumCast(this.props.Document.selectedDoc); //asking to get document at current index - let docAtCurrent = await this.getDocAtIndex(current); - if (docAtCurrent === undefined) { + let docAtCurrentNext = await this.getDocAtIndex(current + 1); + if (docAtCurrentNext === undefined) { return; } //asking for it's presentation id - let curPresId = StrCast(docAtCurrent.presentId); + let curNextPresId = StrCast(docAtCurrentNext.presentId); let nextSelected = current + 1; //if curDoc is in a group, selection slides until last one, if not it's next one - if (this.groupMappings.has(curPresId)) { - let currentsArray = this.groupMappings.get(StrCast(docAtCurrent.presentId))!; - nextSelected = current + currentsArray.length - currentsArray.indexOf(docAtCurrent) - 1; + if (this.groupMappings.has(curNextPresId)) { + let currentsArray = this.groupMappings.get(StrCast(docAtCurrentNext.presentId))!; + nextSelected = current + currentsArray.length - currentsArray.indexOf(docAtCurrentNext); //end of grup so go beyond if (nextSelected === current) nextSelected = current + 1; @@ -126,7 +126,7 @@ export class PresentationView extends React.Component { //checking if this presentation id is mapped to a group, if so chosing the first element in group if (this.groupMappings.has(curPresId)) { let currentsArray = this.groupMappings.get(StrCast(docAtCurrent.presentId))!; - prevSelected = current - currentsArray.length + (currentsArray.length - currentsArray.indexOf(docAtCurrent)); + prevSelected = current - currentsArray.length + (currentsArray.length - currentsArray.indexOf(docAtCurrent)) - 1; //end of grup so go beyond if (prevSelected === current) prevSelected = current - 1; @@ -252,7 +252,7 @@ export class PresentationView extends React.Component { value.splice(index, 1); } } - + @action public gotoDocument = async (index: number) => { const list = FieldValue(Cast(this.props.Document.data, listSpec(Doc))); if (!list) { @@ -261,8 +261,13 @@ export class PresentationView extends React.Component { if (index < 0 || index >= list.length) { return; } - this.props.Document.selectedDoc = index; + + if (!this.presStatus) { + this.presStatus = true; + this.startPresentation(index); + } + const doc = await list[index]; if (this.presStatus) { this.navigateToElement(doc); @@ -301,9 +306,9 @@ export class PresentationView extends React.Component { renderPlayPauseButton = () => { if (this.presStatus) { - return ; + return ; } else { - return ; + return ; } } @@ -314,7 +319,7 @@ export class PresentationView extends React.Component { this.resetPresentation(); } else { this.presStatus = true; - this.startPresentation(); + this.startPresentation(0); } } @@ -332,17 +337,27 @@ export class PresentationView extends React.Component { } - startPresentation = () => { - this.props.Document.selectedDoc = 0; + startPresentation = (startIndex: number) => { let selectedButtons: boolean[]; this.presElementsMappings.forEach((component: PresentationElement, doc: Doc) => { selectedButtons = component.selected; if (selectedButtons[buttonIndex.HideTillPressed]) { - if (this.childrenDocs.indexOf(doc) > 0) { + if (this.childrenDocs.indexOf(doc) > startIndex) { doc.opacity = 0; } } + if (selectedButtons[buttonIndex.HideAfter]) { + if (this.childrenDocs.indexOf(doc) < startIndex) { + doc.opacity = 0; + } + } + if (selectedButtons[buttonIndex.FadeAfter]) { + if (this.childrenDocs.indexOf(doc) < startIndex) { + doc.opacity = 0.5; + } + } + }); } @@ -359,9 +374,9 @@ export class PresentationView extends React.Component {
- + {this.renderPlayPauseButton()} - +
-- cgit v1.2.3-70-g09d2