Skip to content

Commit

Permalink
Fix: remove check for canCycleThroughPagination (fixes #286) (#303)
Browse files Browse the repository at this point in the history
* Fix: remove check for canCycleThroughPagination

* canCycleThroughPagination check removed from setupBackNextLabels
  • Loading branch information
joe-allen-89 authored Jun 11, 2024
1 parent c350f76 commit d16bd53
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions js/NarrativeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,9 @@ class NarrativeView extends ComponentView {
*/
manageBackNextStates(index = this.model.getActiveItem().get('_index')) {
const totalItems = this.model.getChildren().length;
const canCycleThroughPagination = this.model.get('_canCycleThroughPagination');

const shouldEnableBack = index > 0 || canCycleThroughPagination;
const shouldEnableNext = index < totalItems - 1 || canCycleThroughPagination;
const shouldEnableBack = index > 0;
const shouldEnableNext = index < totalItems - 1;

this.model.set('shouldEnableBack', shouldEnableBack);
this.model.set('shouldEnableNext', shouldEnableNext);
Expand All @@ -248,7 +247,6 @@ class NarrativeView extends ComponentView {
*/
setupBackNextLabels(index = this.model.getActiveItem().get('_index')) {
const totalItems = this.model.getChildren().length;
const canCycleThroughPagination = this.model.get('_canCycleThroughPagination');

const isAtStart = index === 0;
const isAtEnd = index === totalItems - 1;
Expand All @@ -262,15 +260,13 @@ class NarrativeView extends ComponentView {
let backItem = isAtStart ? null : index;
let nextItem = isAtEnd ? null : index + 2;

if (canCycleThroughPagination) {
if (isAtStart) {
prevTitle = this.model.getItem(totalItems - 1).get('title');
backItem = totalItems;
}
if (isAtEnd) {
nextTitle = this.model.getItem(0).get('title');
nextItem = 1;
}
if (isAtStart) {
prevTitle = this.model.getItem(totalItems - 1).get('title');
backItem = totalItems;
}
if (isAtEnd) {
nextTitle = this.model.getItem(0).get('title');
nextItem = 1;
}

const backLabel = compile(narrativeGlobals.previous, {
Expand Down

0 comments on commit d16bd53

Please sign in to comment.