Skip to content

Commit

Permalink
Merge pull request #190 from h5p/ji-2975-no-fake-promises
Browse files Browse the repository at this point in the history
JI-2975 no fake promises
  • Loading branch information
thomasmars authored Nov 8, 2021
2 parents fbd4d07 + 8668e95 commit bcd1a03
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
24 changes: 17 additions & 7 deletions src/scripts/cp.js
Original file line number Diff line number Diff line change
Expand Up @@ -1434,13 +1434,13 @@ CoursePresentation.prototype.initKeyEvents = function () {
}

// Left
if ((event.keyCode === 37 || event.keyCode === 33) && that.previousSlide()) {
if ((event.keyCode === 37 || event.keyCode === 33) && that.previousSlide(undefined, false)) {
event.preventDefault();
wait = true;
}

// Right
else if ((event.keyCode === 39 || event.keyCode === 34) && that.nextSlide()) {
else if ((event.keyCode === 39 || event.keyCode === 34) && that.nextSlide(undefined, false)) {
event.preventDefault();
wait = true;
}
Expand Down Expand Up @@ -1572,7 +1572,7 @@ CoursePresentation.prototype.initTouchEvents = function () {

// If we're not scrolling detemine if we're changing slide
var moved = startX - lastX;
if (moved > that.swipeThreshold && that.nextSlide() || moved < -that.swipeThreshold && that.previousSlide()) {
if (moved > that.swipeThreshold && that.nextSlide(undefined, false) || moved < -that.swipeThreshold && that.previousSlide(undefined, false)) {
return;
}
}
Expand Down Expand Up @@ -1646,13 +1646,18 @@ CoursePresentation.prototype.updateTouchPopup = function ($container, slideNumbe
* @param {Boolean} [noScroll] Skip UI scrolling.
* @returns {Boolean} Indicates if the move was made.
*/
CoursePresentation.prototype.previousSlide = function (noScroll) {
CoursePresentation.prototype.previousSlide = function (noScroll, old = true) {
var $prev = this.$current.prev();
if (!$prev.length) {
return false;
}

return this.jumpToSlide($prev.index(), noScroll, false);
if (old) {
return this.processJumpToSlide($prev.index(), noScroll, false);
}
else {
return this.jumpToSlide($prev.index(), noScroll, null, false);
}
};

/**
Expand All @@ -1661,13 +1666,18 @@ CoursePresentation.prototype.previousSlide = function (noScroll) {
* @param {Boolean} noScroll Skip UI scrolling.
* @returns {Boolean} Indicates if the move was made.
*/
CoursePresentation.prototype.nextSlide = function (noScroll) {
CoursePresentation.prototype.nextSlide = function (noScroll, old = true) {
var $next = this.$current.next();
if (!$next.length) {
return false;
}

return this.jumpToSlide($next.index(), noScroll, false);
if (old) {
return this.processJumpToSlide($next.index(), noScroll, false);
}
else {
return this.jumpToSlide($next.index(), noScroll, null, false);
}
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/navigation-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ const NavigationLine = (function ($) {
'aria-disabled': 'true'
}).appendTo($centerFooter);

addClickAndKeyboardListeners(this.cp.$prevSlideButton, () => this.cp.previousSlide());
addClickAndKeyboardListeners(this.cp.$prevSlideButton, () => this.cp.previousSlide(undefined, false));

const $slideNumbering = $('<div/>', {
'class': 'h5p-footer-slide-count'
Expand Down Expand Up @@ -361,7 +361,7 @@ const NavigationLine = (function ($) {
'tabindex': '0'
}).appendTo($centerFooter);

addClickAndKeyboardListeners(this.cp.$nextSlideButton, () => this.cp.nextSlide());
addClickAndKeyboardListeners(this.cp.$nextSlideButton, () => this.cp.nextSlide(undefined, false));

// *********************
// Right footer elements
Expand Down

0 comments on commit bcd1a03

Please sign in to comment.