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: Use transitionsEnded function instead of transitionend event when setting focus (fixes #314) #315

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "adapt-contrib-narrative",
"version": "7.10.1",
"framework": ">=5.35.6",
"framework": ">=5.39.6",
"homepage": "https://github.com/adaptlearning/adapt-contrib-narrative",
"bugs": "https://github.com/adaptlearning/adapt-contrib-narrative/issues",
"component": "narrative",
Expand Down
10 changes: 4 additions & 6 deletions js/NarrativeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import notify from 'core/js/notify';
import ComponentView from 'core/js/views/componentView';
import MODE from './modeEnum';
import { compile } from 'core/js/reactHelpers';
import { transitionsEnded } from 'core/js/transitions';

class NarrativeView extends ComponentView {

Expand Down Expand Up @@ -40,15 +41,12 @@ class NarrativeView extends ComponentView {
this.calculateWidths();
}

setFocus(itemIndex) {
async setFocus(itemIndex) {
const $animatedElement = this.isLargeMode() || this.model.get('_isMobileTextBelowImage')
? this.$('.narrative__slider')
: this.$('.narrative__strapline-header-inner');
const hasAnimation = ($animatedElement.css('transitionDuration') !== '0s');
if (hasAnimation) {
$animatedElement.one('transitionend', () => this.focusOnNarrativeElement(itemIndex));
return;
}
await transitionsEnded($animatedElement);

// Allow dom to settle before moving focus
requestAnimationFrame(() => {
this.focusOnNarrativeElement(itemIndex);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "adapt-contrib-narrative",
"version": "7.10.1",
"framework": ">=5.35.6",
"framework": ">=5.39.6",
"homepage": "https://github.com/adaptlearning/adapt-contrib-narrative",
"bugs": "https://github.com/adaptlearning/adapt-contrib-narrative/issues",
"component": "narrative",
Expand Down
Loading