Skip to content

Commit 87c4656

Browse files
adamgyulavariKylie Stewart
authored andcommitted
add deck option to disable touch events (#745)
1 parent 73122da commit 87c4656

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ The Deck tag is the root level tag for your presentation. It supports the follow
491491
| contentHeight | PropTypes.numbers | Baseline content area height. | `700px` |
492492
| contentWidth | PropTypes.numbers | Baseline content area width. | `1000px` |
493493
| disableKeyboardControls | PropTypes.bool | Toggle keyboard control. | `false` |
494+
| disableTouchControls | PropTypes.bool | Toggle touch control. | `false` |
494495
| onStateChange | PropTypes.func | Called whenever a new slide becomes visible with the arguments `(previousState, nextState)` where state refers to the outgoing and incoming `<Slide />`'s `state` props, respectively. The default implementation attaches the current state as a class to the document root. | see description |
495496
| history | PropTypes.object | Accepts custom configuration for [history](https://github.com/ReactTraining/history). | |
496497
| progress | PropTypes.string | Accepts `pacman`, `bar`, `number` or `none`. To override the color, change the 'quaternary' color in the theme. | `pacman` |

index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ declare module 'spectacle' {
169169
autoplayLoop?: boolean;
170170
autoplayOnStart?: boolean;
171171
controls?: boolean;
172+
disableKeyboardControls?: boolean;
173+
disableTouchControls?: boolean;
172174
globalStyles?: boolean;
173175
history?: any; // Needs a type, see https://github.com/ReactTraining/history
174176
showFullscreenControl?: boolean;

src/components/__snapshots__/manager.test.js.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ exports[`<Manager /> should render correctly. 1`] = `
1919
contentWidth={1000}
2020
controls={true}
2121
disableKeyboardControls={false}
22+
disableTouchControls={false}
2223
dispatch={[Function]}
2324
fragment={
2425
Object {
@@ -357,6 +358,7 @@ exports[`<Manager /> should render fullscreen button dependant on prop 1`] = `
357358
contentWidth={1000}
358359
controls={true}
359360
disableKeyboardControls={false}
361+
disableTouchControls={false}
360362
dispatch={[Function]}
361363
fragment={
362364
Object {
@@ -663,6 +665,7 @@ exports[`<Manager /> should render the export configuration when specified. 1`]
663665
contentWidth={1000}
664666
controls={true}
665667
disableKeyboardControls={false}
668+
disableTouchControls={false}
666669
dispatch={[Function]}
667670
fragment={
668671
Object {
@@ -798,6 +801,7 @@ exports[`<Manager /> should render the overview configuration when specified. 1`
798801
contentWidth={1000}
799802
controls={true}
800803
disableKeyboardControls={false}
804+
disableTouchControls={false}
801805
dispatch={[Function]}
802806
fragment={
803807
Object {
@@ -959,6 +963,7 @@ exports[`<Manager /> should render with slideset slides 1`] = `
959963
contentWidth={1000}
960964
controls={true}
961965
disableKeyboardControls={false}
966+
disableTouchControls={false}
962967
dispatch={[Function]}
963968
fragment={
964969
Object {

src/components/deck.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default class Deck extends Component {
3030
children: PropTypes.node,
3131
controls: PropTypes.bool,
3232
disableKeyboardControls: PropTypes.bool,
33+
disableTouchControls: PropTypes.bool,
3334
globalStyles: PropTypes.bool,
3435
history: PropTypes.object,
3536
onStateChange: PropTypes.func,

src/components/manager.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export class Manager extends Component {
110110
contentWidth: PropTypes.number,
111111
controls: PropTypes.bool,
112112
disableKeyboardControls: PropTypes.bool,
113+
disableTouchControls: PropTypes.bool,
113114
dispatch: PropTypes.func,
114115
fragment: PropTypes.object,
115116
globalStyles: PropTypes.bool,
@@ -145,6 +146,7 @@ export class Manager extends Component {
145146
contentWidth: 1000,
146147
contentHeight: 700,
147148
disableKeyboardControls: false,
149+
disableTouchControls: false,
148150
transition: [],
149151
transitionDuration: 500,
150152
progress: 'pacman',
@@ -636,6 +638,9 @@ export class Manager extends Component {
636638
}
637639
}
638640
_getTouchEvents() {
641+
if (this.props.disableTouchControls) {
642+
return {};
643+
}
639644
const self = this;
640645

641646
return {

0 commit comments

Comments
 (0)