Skip to content

Commit

Permalink
Fix: Prevent scrolling of container (fixes #254) (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster committed Apr 3, 2023
1 parent 75e1cd7 commit cb6a6e9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion js/NarrativeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class NarrativeView extends ComponentView {
this.renderMode();
this.setupNarrative();

this.$('.narrative__slider').imageready(this.setReadyStatus.bind(this));
this.$('.narrative__slider').imageready(this.setReadyStatus.bind(this));
this.$('.narrative__slide-container')[0]?.addEventListener('scroll', this.onScroll, true);
}

setupNarrative() {
Expand Down Expand Up @@ -298,6 +299,11 @@ class NarrativeView extends ComponentView {
let index = this.model.getActiveItem().get('_index');
this.model.setActiveItem(--index);
}

onScroll (event) {
event.preventDefault();
event.target.scrollTo(0, 0);
}

/**
* In mobile view, highlight instruction if user navigates to another
Expand All @@ -314,6 +320,10 @@ class NarrativeView extends ComponentView {
this.setupInviewCompletion('.component__widget');
}
}

preRemove() {
this.$('.narrative__slide-container')[0]?.removeEventListener('scroll', this.onScroll, true);
}
}

NarrativeView.template = 'narrative.jsx';
Expand Down

0 comments on commit cb6a6e9

Please sign in to comment.