Skip to content

Commit

Permalink
focus sur pagination et fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Clararigaud committed Sep 26, 2024
1 parent 1eecbee commit bc26099
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions assets/js/theme/components/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ window.osuny.carousel.Carousel.prototype = {
this.pagination = new window.osuny.carousel.Pagination(paginationElement);
if (paginationElement) {
paginationElement.addEventListener(window.osuny.carousel.events.paginationButtonClicked, this._onPaginationButtonClicked.bind(this));
paginationElement.addEventListener(window.osuny.carousel.events.controlFocused, function () {
this.autoplayer.pause();
}.bind(this));
}
},
_initializeArrows: function () {
Expand Down Expand Up @@ -125,9 +128,6 @@ window.osuny.carousel.Carousel.prototype = {
this.element.addEventListener('touchstart', this._pointerStart.bind(this));
this.element.addEventListener('mouseleave', this._pointerEnd.bind(this));
this.element.addEventListener('touchend', this._pointerEnd.bind(this));
this.element.addEventListener('focusin', function () {
this.autoplayer.pause();
}.bind(this));
},
_onAutoplayerProgression: function (event) {
this.pagination.setProgression(event.value);
Expand Down
3 changes: 2 additions & 1 deletion assets/js/theme/components/carousel/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ window.osuny.carousel.events = {
arrowsNext: 'osuny.carousel.arrows.next',
arrowsPrevious: 'osuny.carousel.arrows.previous',
paginationButtonClicked: 'osuny.carousel.pagination.buttonClicked',
instanciated: 'osuny.carousel.instanciated'
instanciated: 'osuny.carousel.instanciated',
controlFocused: 'osuny.carousel.controlFocused'
};
5 changes: 5 additions & 0 deletions assets/js/theme/components/carousel/paginationButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ window.osuny.carousel.PaginationButton = function PaginationButton (element, ind
this.progressBar = this.element.querySelector('i');
this.setProgression(0);
this.element.addEventListener('click', this._onClick.bind(this));
this.element.addEventListener('focusin', this._onFocus.bind(this));
};

window.osuny.carousel.PaginationButton.prototype = {
Expand All @@ -31,6 +32,10 @@ window.osuny.carousel.PaginationButton.prototype = {
event.index = this.index;
this.pagination.dispatchEvent(event);
},
_onFocus: function () {
var event = new Event(window.osuny.carousel.events.controlFocused);
this.pagination.dispatchEvent(event);
},
setAriaCurrent (current) {
this.element.setAttribute('aria-current', String(current));
}
Expand Down
1 change: 0 additions & 1 deletion assets/js/theme/components/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ window.osuny.components.events = {
handleKeyDownEvent: function (e) {
var target = this._getEventTarget();
if (target) {
e.preventDefault();
if (e.key === 'ArrowLeft') {
target.previous();
} else if (e.key === 'ArrowRight') {
Expand Down
1 change: 0 additions & 1 deletion assets/js/theme/components/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ window.osuny.components.utils = {
return this.element.getElementsByClassName(className).item(0);
},
dispatchEvent: function (eventKey, value = null) {
console.log(value)
var eventName = this.environment.events[eventKey],
event = new Event(eventName);
event.value = value;
Expand Down

0 comments on commit bc26099

Please sign in to comment.