Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Prevent scrolling of container (fixes #254) #255

Merged
merged 3 commits into from
Apr 3, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
oliverfoster marked this conversation as resolved.
Show resolved Hide resolved
}
}

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