Skip to content

Commit

Permalink
Merge pull request #30 from erichbehrens/feature/touchDisabled
Browse files Browse the repository at this point in the history
Implement touchDisabled prop
  • Loading branch information
erichbehrens authored Mar 6, 2018
2 parents 47386de + 60f24f2 commit 524a44f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ Enable or disable infinite loop through slides. Sliders with only 2 children wil

Autoplay interval in miliseconds. If `undefined` the slider will not play automatically. The timer will be paused and reset during user interactions such as mouse over or touch, to avoid sliding away the elements when the user wants to click them.

**touchDisabled** `boolean`, default `false`

Disable slider navigation through touch events

**minSwipeOffset** - `number`, default `15`(px)

Minimum distance to swipe for triggering a navigation event
Expand Down
6 changes: 3 additions & 3 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,16 @@ var Slider = function (_React$PureComponent) {
previousButton = _props$previousButton === undefined ? 'previous' : _props$previousButton,
_props$nextButton = _props.nextButton,
nextButton = _props$nextButton === undefined ? 'next' : _props$nextButton,
touchDisabled = _props.touchDisabled,
autoplay = _props.autoplay;

var classNames = this.getClassNames();
var isDisabled = this.isDisabled();
return _react2.default.createElement(
'div',
_extends({
className: className,
ref: this.initTouchEvents
}, autoplay && {
className: className
}, !touchDisabled && { ref: this.initTouchEvents }, autoplay && {
onMouseOver: this.handleMouseOver,
onMouseOut: this.handleMouseOut
}),
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-animated-slider",
"version": "0.5.0",
"version": "0.5.1",
"description": "Animated slider component for react",
"main": "build/index.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,15 @@ class Slider extends React.PureComponent {
className,
previousButton = 'previous',
nextButton = 'next',
touchDisabled,
autoplay,
} = this.props;
const classNames = this.getClassNames();
const isDisabled = this.isDisabled();
return (
<div
className={className}
ref={this.initTouchEvents}
{...!touchDisabled && { ref: this.initTouchEvents }}
{...autoplay && {
onMouseOver: this.handleMouseOver,
onMouseOut: this.handleMouseOut,
Expand Down

0 comments on commit 524a44f

Please sign in to comment.