Skip to content

Commit

Permalink
issue/3070 Mobile instruction highlighting for interaction error
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster authored Apr 12, 2021
2 parents 92c5dd2 + 4278588 commit e5824d7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion js/narrativeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ define([

this.evaluateNavigation();
this.evaluateCompletion();
this.shouldShowInstructionError();
this.moveSliderToIndex(index);
}

Expand Down Expand Up @@ -280,6 +281,7 @@ define([
evaluateCompletion() {
if (this.model.areAllItemsCompleted()) {
this.trigger('allItems');
this.$('.narrative__instruction-inner').removeClass('instruction-error');
}
}

Expand Down Expand Up @@ -308,12 +310,21 @@ define([
this.model.setActiveItem(index);
}

/**
* In mobile view, highlight instruction if user navigates to another
* item before completing, in case the strapline is missed
*/
shouldShowInstructionError() {
const prevItemIndex = this.model.getActiveItem().get('_index') - 1;
if (prevItemIndex < 0 || this.model.getItem(prevItemIndex).get('_isVisited')) return;
this.$('.narrative__instruction-inner').addClass('instruction-error');
}

setupEventListeners() {
if (this.model.get('_setCompletionOn') === 'inview') {
this.setupInviewCompletion('.component__widget');
}
}

}

NarrativeView.template = 'narrative';
Expand Down

0 comments on commit e5824d7

Please sign in to comment.