forked from akiran/react-slick
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add onSwipeStart and onSwipeEnd hooks
- Loading branch information
mivl
committed
Apr 15, 2019
1 parent
2b7e78c
commit b03e402
Showing
4 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React, { Component } from "react"; | ||
import Slider from "../src/slider"; | ||
|
||
export default class SimpleSlider extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
dragging: false | ||
}; | ||
} | ||
|
||
onSwipeStart() { | ||
this.setState({ | ||
dragging: true | ||
}); | ||
} | ||
|
||
onSwipeEnd() { | ||
this.setState({ | ||
dragging: false | ||
}); | ||
} | ||
|
||
render() { | ||
const { dragging } = this.state; | ||
const settings = { | ||
dots: true, | ||
infinite: true, | ||
speed: 500, | ||
slidesToShow: 1, | ||
slidesToScroll: 1, | ||
onSwipeStart: () => this.onSwipeStart(), | ||
onSwipeEnd: () => this.onSwipeEnd() | ||
}; | ||
return ( | ||
<div> | ||
<h2> OnSwipe hooks</h2> | ||
<Slider {...settings}> | ||
<div> | ||
<h3>1</h3> | ||
</div> | ||
<div> | ||
<h3>2</h3> | ||
</div> | ||
<div> | ||
<h3>3</h3> | ||
</div> | ||
<div> | ||
<h3>4</h3> | ||
</div> | ||
<div> | ||
<h3>5</h3> | ||
</div> | ||
<div> | ||
<h3>6</h3> | ||
</div> | ||
</Slider> | ||
<p>{dragging ? "dragging" : "not dragging"}</p> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters