Skip to content

Commit 5dd1b9c

Browse files
Firing show event on the slide
Fixes webslides#104
1 parent ed93fd8 commit 5dd1b9c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/js/modules/slide.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ const CLASSES = {
88
const Events = {
99
ENTER: 'dom:enter',
1010
LEAVE: 'dom:leave',
11+
DISABLE: 'slide:disable',
1112
ENABLE: 'slide:enable',
12-
DISABLE: 'slide:disable'
13+
SHOW: 'slide:show'
1314
};
1415

1516
/**
@@ -57,6 +58,7 @@ class Slide {
5758
show() {
5859
DOM.show(this.el);
5960
this.el.classList.add(CLASSES.CURRENT);
61+
this.fire_(Events.SHOW);
6062
}
6163

6264
/**

test/modules/slide.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,36 +71,42 @@ describe('Slide module', () => {
7171
const enter = jest.fn();
7272
const enable = jest.fn();
7373
const disable = jest.fn();
74+
const show = jest.fn();
7475

7576
slide.el.addEventListener('dom:leave', leave);
7677
slide.el.addEventListener('dom:enter', enter);
7778
slide.el.addEventListener('slide:enable', enable);
7879
slide.el.addEventListener('slide:disable', disable);
80+
slide.el.addEventListener('slide:show', show);
7981

8082
expect(enter).not.toHaveBeenCalled();
8183
expect(leave).not.toHaveBeenCalled();
8284
expect(enable).not.toHaveBeenCalled();
8385
expect(disable).not.toHaveBeenCalled();
86+
expect(show).not.toHaveBeenCalled();
8487

8588
slide.enable();
8689
expect(enter).not.toHaveBeenCalled();
8790
expect(leave).not.toHaveBeenCalled();
8891
expect(enable).toHaveBeenCalledTimes(1);
8992
expect(disable).not.toHaveBeenCalled();
93+
expect(show).not.toHaveBeenCalled();
9094
enable.mockClear();
9195

9296
slide.disable();
9397
expect(enter).not.toHaveBeenCalled();
9498
expect(leave).not.toHaveBeenCalled();
9599
expect(enable).not.toHaveBeenCalled();
96100
expect(disable).toHaveBeenCalledTimes(1);
101+
expect(show).not.toHaveBeenCalled();
97102
disable.mockClear();
98103

99104
slide.moveAfterLast();
100105
expect(enter).toHaveBeenCalledTimes(1);
101106
expect(leave).toHaveBeenCalledTimes(1);
102107
expect(enable).not.toHaveBeenCalled();
103108
expect(disable).not.toHaveBeenCalled();
109+
expect(show).not.toHaveBeenCalled();
104110
enter.mockClear();
105111
leave.mockClear();
106112

@@ -109,8 +115,12 @@ describe('Slide module', () => {
109115
expect(leave).toHaveBeenCalledTimes(1);
110116
expect(enable).not.toHaveBeenCalled();
111117
expect(disable).not.toHaveBeenCalled();
118+
expect(show).not.toHaveBeenCalled();
112119
enter.mockClear();
113120
leave.mockClear();
121+
122+
slide.show();
123+
expect(show).toHaveBeenCalled();
114124
});
115125

116126
test('Move', () => {

0 commit comments

Comments
 (0)