Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit cd06c76

Browse files
feat: add an optional option to not performed the inner slide animation on slideNext and slidePrev
1 parent 90df088 commit cd06c76

File tree

3 files changed

+36
-14
lines changed

3 files changed

+36
-14
lines changed

doc/features/navigation.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Furthermore than the default swiping, the [DeckDeckGo] deck expose the following
66

77
- [Navigation](#navigation)
88
- [Go to next slide](#go-to-next-slide)
9+
- [Optional parameters](#pptional-parameters)
910
- [Go to previous slide](#go-to-previous-slide)
11+
- [Optional parameters](#pptional-parameters)
1012
- [Go to a specific slide](#go-to-a-specific-slide)
1113
- [Is the deck at the begin](#is-the-deck-at-the-begin)
1214
- [Is the deck at the end](#is-the-deck-at-the-end)
@@ -32,10 +34,17 @@ const deck = document.getElementsByTagName('deckgo-deck');
3234
await deck.slideNext();
3335
```
3436

35-
*Optional parameter:* Optionally your could provide a boolean parameter to this method in case you would not like the event `slideNextDidChange` and `slidePrevDidChange` to be fired.
37+
For example:
38+
39+
#### Optional parameters
40+
41+
| Parameter | Type | Default | Description |
42+
| -------------------------- |:-----------------:|:-----------------:|:-----------------:|
43+
| slideAnimation | boolean | true | Set to `false` in case you would not like the inner animation of a slide, like the reveal or code animation for example, to be performed. |
44+
| emitEvent | boolean | true | Set to `false` in case you would not like the events `slideNextDidChange` and `slidePrevDidChange` to be fired. Note that to use this parameter, the previous should be set too. |
3645

3746
```
38-
await deck.slideNext(false);
47+
await deck.slideNext(false, false);
3948
```
4049

4150
### Go to previous slide
@@ -44,10 +53,17 @@ await deck.slideNext(false);
4453
await deck.slidePrev();
4554
```
4655

47-
*Optional parameter:* Optionally your could provide a boolean parameter to this method in case you would not like the event `slideNextDidChange` and `slidePrevDidChange` to be fired.
56+
#### Optional parameters
57+
58+
| Parameter | Type | Default | Description |
59+
| -------------------------- |:-----------------:|:-----------------:|:-----------------:|
60+
| slideAnimation | boolean | true | Set to `false` in case you would not like the inner animation of a slide, like the reveal or code animation for example, to be performed. |
61+
| emitEvent | boolean | true | Set to `false` in case you would not like the events `slideNextDidChange` and `slidePrevDidChange` to be fired. Note that to use this parameter, the previous should be set too. |
62+
63+
For example:
4864

4965
```
50-
await deck.slidePrev(false);
66+
await deck.slidePrev(false, false);
5167
```
5268

5369
### Go to a specific slide

src/components.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ export namespace Components {
2121
'keyboard': boolean;
2222
'pager': boolean;
2323
'pagerPercentage': boolean;
24-
'slideNext': (emitEvent?: boolean) => Promise<void>;
25-
'slidePrev': (emitEvent?: boolean) => Promise<void>;
24+
'slideNext': (slideAnimation?: boolean, emitEvent?: boolean) => Promise<void>;
25+
'slidePrev': (slideAnimation?: boolean, emitEvent?: boolean) => Promise<void>;
2626
'slideTo': (index: number, speed?: number) => Promise<void>;
2727
'toggleFullScreen': () => Promise<void>;
2828
}
2929
interface DeckgoDeckAttributes extends StencilHTMLAttributes {
3030
'keyboard'?: boolean;
3131
'onSlideDrag'?: (event: CustomEvent<number>) => void;
32-
'onSlideNextStart'?: (event: CustomEvent<number>) => void;
33-
'onSlidePrevStart'?: (event: CustomEvent<number>) => void;
32+
'onSlideNextDidChange'?: (event: CustomEvent<number>) => void;
33+
'onSlidePrevDidChange'?: (event: CustomEvent<number>) => void;
3434
'onSlideWillChange'?: (event: CustomEvent<number>) => void;
3535
'pager'?: boolean;
3636
'pagerPercentage'?: boolean;

src/components/deck/deckdeckgo-deck/deckdeckgo-deck.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,23 +281,29 @@ export class DeckdeckgoDeck {
281281
/* BEGIN: Manual sliding */
282282

283283
@Method()
284-
async slideNext(emitEvent?: boolean) {
285-
await this.slideNextPrev(true, emitEvent);
284+
async slideNext(slideAnimation?: boolean, emitEvent?: boolean) {
285+
await this.slideNextPrev(true, slideAnimation, emitEvent);
286286
}
287287

288288
@Method()
289-
async slidePrev(emitEvent?: boolean) {
290-
await this.slideNextPrev(false, emitEvent);
289+
async slidePrev(slideAnimation?: boolean, emitEvent?: boolean) {
290+
await this.slideNextPrev(false, slideAnimation, emitEvent);
291291
}
292292

293-
private async slideNextPrev(swipeLeft: boolean, emitEvent?: boolean) {
293+
private async slideNextPrev(swipeLeft: boolean, slideAnimation: boolean = true, emitEvent?: boolean) {
294294
const slider: HTMLElement = this.el.shadowRoot.querySelector('div.deckgo-deck');
295295

296296
if (!slider || !window) {
297297
return;
298298
}
299299

300-
const couldSwipe: boolean = await this.couldSwipe(swipeLeft);
300+
let couldSwipe: boolean;
301+
302+
if (!slideAnimation) {
303+
couldSwipe = true;
304+
} else {
305+
couldSwipe = await this.couldSwipe(swipeLeft);
306+
}
301307

302308
// We might want first to show hide stuffs in the slide before swiping
303309
if (couldSwipe) {

0 commit comments

Comments
 (0)