Skip to content

Commit 62fd590

Browse files
authored
Merge pull request #1029 from akiran/examples
slickPause and slickPlay example
2 parents 81df845 + 0d44e2e commit 62fd590

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

docs/demos.jsx

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import UnevenSetsFinite from '../examples/UnevenSetsFinite'
1212
import CenterMode from '../examples/CenterMode'
1313
import FocusOnSelect from '../examples/FocusOnSelect'
1414
import AutoPlay from '../examples/AutoPlay'
15+
import AutoPlayMethods from '../examples/AutoPlayMethods'
1516
import PauseOnHover from '../examples/PauseOnHover'
1617
import Rtl from '../examples/Rtl'
1718
import VariableWidth from '../examples/VariableWidth'
@@ -40,6 +41,7 @@ export default class App extends React.Component {
4041
<CenterMode />
4142
<FocusOnSelect />
4243
<AutoPlay />
44+
<AutoPlayMethods />
4345
<PauseOnHover />
4446
<Rtl />
4547
<VariableWidth />

examples/AutoPlayMethods.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React, { Component } from 'react'
2+
import Slider from '../src/slider'
3+
4+
export default class AutoPlayMethods extends Component {
5+
constructor(props) {
6+
super(props)
7+
this.play = this.play.bind(this)
8+
this.pause = this.pause.bind(this)
9+
}
10+
play() {
11+
this.slider.slickPlay()
12+
}
13+
pause() {
14+
this.slider.slickPause()
15+
}
16+
render() {
17+
const settings = {
18+
dots: true,
19+
infinite: true,
20+
slidesToShow: 3,
21+
slidesToScroll: 1,
22+
autoplay: true,
23+
autoplaySpeed: 2000
24+
};
25+
return (
26+
<div>
27+
<h2>Auto Play & Pause with buttons</h2>
28+
<Slider ref={slider => this.slider = slider} {...settings}>
29+
<div><h3>1</h3></div>
30+
<div><h3>2</h3></div>
31+
<div><h3>3</h3></div>
32+
<div><h3>4</h3></div>
33+
<div><h3>5</h3></div>
34+
<div><h3>6</h3></div>
35+
</Slider>
36+
<div style={{textAlign: 'center'}}>
37+
<button className='button' onClick={this.play}>Play</button>
38+
<button className='button' onClick={this.pause}>Pause</button>
39+
</div>
40+
</div>
41+
);
42+
}
43+
}

0 commit comments

Comments
 (0)