-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectionButtonManager.js
More file actions
32 lines (27 loc) · 963 Bytes
/
DirectionButtonManager.js
File metadata and controls
32 lines (27 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import SlideComponent from "./SlideComponent.js";
const DirectionEnum = Object.freeze({"left": 0, "right": 1})
class DirectionButtonManager extends SlideComponent {
constructor(slideService, buttons) {
super(slideService, buttons);
}
//Override
_registerEventListenerOnElements(slideService, elements) {
elements.forEach((element, index) => {
element.addEventListener('click', event => {
this._directionButtonHandler(event, slideService, index);
});
});
}
_directionButtonHandler(event, slideService, direction) {
if (DirectionEnum.left === direction) {
slideService.mediate('decreaseCurrentIndex');
}
else if (DirectionEnum.right === direction) {
slideService.mediate('increaseCurrentIndex');
}
else {
throw new Error("Undefined button.");
}
}
}
export default DirectionButtonManager;