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.
- Loading branch information
1 parent
4b7a26b
commit bae95d7
Showing
14 changed files
with
2,186 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ demos/* | |
demos1 | ||
TODO.md | ||
npm-debug.log | ||
lib | ||
|
||
*.sublime-* | ||
.idea | ||
dist | ||
|
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,136 @@ | ||
'use strict'; | ||
|
||
exports.__esModule = true; | ||
exports.NextArrow = exports.PrevArrow = undefined; | ||
|
||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
|
||
var _react = require('react'); | ||
|
||
var _react2 = _interopRequireDefault(_react); | ||
|
||
var _classnames = require('classnames'); | ||
|
||
var _classnames2 = _interopRequireDefault(_classnames); | ||
|
||
var _helpers = require('./mixins/helpers'); | ||
|
||
var _helpers2 = _interopRequireDefault(_helpers); | ||
|
||
var _innerSliderUtils = require('./utils/innerSliderUtils'); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
|
||
var PrevArrow = exports.PrevArrow = function (_React$Component) { | ||
_inherits(PrevArrow, _React$Component); | ||
|
||
function PrevArrow() { | ||
_classCallCheck(this, PrevArrow); | ||
|
||
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); | ||
} | ||
|
||
PrevArrow.prototype.clickHandler = function clickHandler(options, e) { | ||
if (e) { | ||
e.preventDefault(); | ||
} | ||
this.props.clickHandler(options, e); | ||
}; | ||
|
||
PrevArrow.prototype.render = function render() { | ||
var prevClasses = { 'slick-arrow': true, 'slick-prev': true }; | ||
var prevHandler = this.clickHandler.bind(this, { message: 'previous' }); | ||
|
||
if (!this.props.infinite && (this.props.currentSlide === 0 || this.props.slideCount <= this.props.slidesToShow)) { | ||
prevClasses['slick-disabled'] = true; | ||
prevHandler = null; | ||
} | ||
|
||
var prevArrowProps = { | ||
key: '0', | ||
'data-role': 'none', | ||
className: (0, _classnames2.default)(prevClasses), | ||
style: { display: 'block' }, | ||
onClick: prevHandler | ||
}; | ||
var customProps = { | ||
currentSlide: this.props.currentSlide, | ||
slideCount: this.props.slideCount | ||
}; | ||
var prevArrow = void 0; | ||
|
||
if (this.props.prevArrow) { | ||
prevArrow = _react2.default.cloneElement(this.props.prevArrow, _extends({}, prevArrowProps, customProps)); | ||
} else { | ||
prevArrow = _react2.default.createElement( | ||
'button', | ||
_extends({ key: '0', type: 'button' }, prevArrowProps), | ||
' Previous' | ||
); | ||
} | ||
|
||
return prevArrow; | ||
}; | ||
|
||
return PrevArrow; | ||
}(_react2.default.Component); | ||
|
||
var NextArrow = exports.NextArrow = function (_React$Component2) { | ||
_inherits(NextArrow, _React$Component2); | ||
|
||
function NextArrow() { | ||
_classCallCheck(this, NextArrow); | ||
|
||
return _possibleConstructorReturn(this, _React$Component2.apply(this, arguments)); | ||
} | ||
|
||
NextArrow.prototype.clickHandler = function clickHandler(options, e) { | ||
if (e) { | ||
e.preventDefault(); | ||
} | ||
this.props.clickHandler(options, e); | ||
}; | ||
|
||
NextArrow.prototype.render = function render() { | ||
var nextClasses = { 'slick-arrow': true, 'slick-next': true }; | ||
var nextHandler = this.clickHandler.bind(this, { message: 'next' }); | ||
|
||
if (!(0, _innerSliderUtils.canGoNext)(this.props)) { | ||
nextClasses['slick-disabled'] = true; | ||
nextHandler = null; | ||
} | ||
|
||
var nextArrowProps = { | ||
key: '1', | ||
'data-role': 'none', | ||
className: (0, _classnames2.default)(nextClasses), | ||
style: { display: 'block' }, | ||
onClick: nextHandler | ||
}; | ||
var customProps = { | ||
currentSlide: this.props.currentSlide, | ||
slideCount: this.props.slideCount | ||
}; | ||
var nextArrow = void 0; | ||
|
||
if (this.props.nextArrow) { | ||
nextArrow = _react2.default.cloneElement(this.props.nextArrow, _extends({}, nextArrowProps, customProps)); | ||
} else { | ||
nextArrow = _react2.default.createElement( | ||
'button', | ||
_extends({ key: '1', type: 'button' }, nextArrowProps), | ||
' Next' | ||
); | ||
} | ||
|
||
return nextArrow; | ||
}; | ||
|
||
return NextArrow; | ||
}(_react2.default.Component); |
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,71 @@ | ||
'use strict'; | ||
|
||
exports.__esModule = true; | ||
|
||
var _react = require('react'); | ||
|
||
var _react2 = _interopRequireDefault(_react); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
var defaultProps = { | ||
className: '', | ||
accessibility: true, | ||
adaptiveHeight: false, | ||
arrows: true, | ||
autoplay: false, | ||
autoplaySpeed: 3000, | ||
centerMode: false, | ||
centerPadding: '50px', | ||
cssEase: 'ease', | ||
customPaging: function customPaging(i) { | ||
return _react2.default.createElement( | ||
'button', | ||
null, | ||
i + 1 | ||
); | ||
}, | ||
dots: false, | ||
dotsClass: 'slick-dots', | ||
draggable: true, | ||
easing: 'linear', | ||
edgeFriction: 0.35, | ||
fade: false, | ||
focusOnSelect: false, | ||
infinite: true, | ||
initialSlide: 0, | ||
lazyLoad: false, | ||
pauseOnHover: true, | ||
responsive: null, | ||
rtl: false, | ||
slide: 'div', | ||
slidesToShow: 1, | ||
slidesToScroll: 1, | ||
speed: 500, | ||
swipe: true, | ||
swipeToSlide: false, | ||
touchMove: true, | ||
touchThreshold: 5, | ||
useCSS: true, | ||
variableWidth: false, | ||
vertical: false, | ||
waitForAnimate: true, | ||
afterChange: null, | ||
beforeChange: null, | ||
edgeEvent: null, | ||
// init: function hook that gets called right before InnerSlider mounts | ||
init: null, | ||
swipeEvent: null, | ||
// nextArrow, prevArrow should react componets | ||
nextArrow: null, | ||
prevArrow: null, | ||
appendDots: function appendDots(dots) { | ||
return _react2.default.createElement( | ||
'ul', | ||
{ style: { display: 'block' } }, | ||
dots | ||
); | ||
} | ||
}; | ||
|
||
exports.default = defaultProps; |
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,91 @@ | ||
'use strict'; | ||
|
||
exports.__esModule = true; | ||
exports.Dots = undefined; | ||
|
||
var _react = require('react'); | ||
|
||
var _react2 = _interopRequireDefault(_react); | ||
|
||
var _classnames = require('classnames'); | ||
|
||
var _classnames2 = _interopRequireDefault(_classnames); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
|
||
var getDotCount = function getDotCount(spec) { | ||
var dots; | ||
|
||
if (spec.infinite) { | ||
dots = Math.ceil(spec.slideCount / spec.slidesToScroll); | ||
} else { | ||
dots = Math.ceil((spec.slideCount - spec.slidesToShow) / spec.slidesToScroll) + 1; | ||
} | ||
|
||
return dots; | ||
}; | ||
|
||
var Dots = exports.Dots = function (_React$Component) { | ||
_inherits(Dots, _React$Component); | ||
|
||
function Dots() { | ||
_classCallCheck(this, Dots); | ||
|
||
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); | ||
} | ||
|
||
Dots.prototype.clickHandler = function clickHandler(options, e) { | ||
// In Autoplay the focus stays on clicked button even after transition | ||
// to next slide. That only goes away by click somewhere outside | ||
e.preventDefault(); | ||
this.props.clickHandler(options); | ||
}; | ||
|
||
Dots.prototype.render = function render() { | ||
var _this2 = this; | ||
|
||
var dotCount = getDotCount({ | ||
slideCount: this.props.slideCount, | ||
slidesToScroll: this.props.slidesToScroll, | ||
slidesToShow: this.props.slidesToShow, | ||
infinite: this.props.infinite | ||
}); | ||
|
||
// Apply join & split to Array to pre-fill it for IE8 | ||
// | ||
// Credit: http://stackoverflow.com/a/13735425/1849458 | ||
var dots = Array.apply(null, Array(dotCount + 1).join('0').split('')).map(function (x, i) { | ||
|
||
var leftBound = i * _this2.props.slidesToScroll; | ||
var rightBound = i * _this2.props.slidesToScroll + (_this2.props.slidesToScroll - 1); | ||
var className = (0, _classnames2.default)({ | ||
'slick-active': _this2.props.currentSlide >= leftBound && _this2.props.currentSlide <= rightBound | ||
}); | ||
|
||
var dotOptions = { | ||
message: 'dots', | ||
index: i, | ||
slidesToScroll: _this2.props.slidesToScroll, | ||
currentSlide: _this2.props.currentSlide | ||
}; | ||
|
||
var onClick = _this2.clickHandler.bind(_this2, dotOptions); | ||
|
||
return _react2.default.createElement( | ||
'li', | ||
{ key: i, className: className }, | ||
_react2.default.cloneElement(_this2.props.customPaging(i), { onClick: onClick }) | ||
); | ||
}); | ||
|
||
return _react2.default.cloneElement(this.props.appendDots(dots), { className: this.props.dotsClass }); | ||
}; | ||
|
||
return Dots; | ||
}(_react2.default.Component); |
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,11 @@ | ||
'use strict'; | ||
|
||
exports.__esModule = true; | ||
|
||
var _slider = require('./slider'); | ||
|
||
var _slider2 = _interopRequireDefault(_slider); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
exports.default = _slider2.default; |
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,47 @@ | ||
"use strict"; | ||
|
||
var initialState = { | ||
animating: false, | ||
dragging: false, | ||
currentDirection: 0, | ||
currentLeft: null, | ||
currentSlide: 0, | ||
direction: 1, | ||
listWidth: null, | ||
listHeight: null, | ||
scrolling: false, | ||
// loadIndex: 0, | ||
slideCount: null, | ||
slideWidth: null, | ||
slideHeight: null, | ||
swiping: false, | ||
// sliding: false, | ||
// slideOffset: 0, | ||
swipeLeft: null, | ||
touchObject: { | ||
startX: 0, | ||
startY: 0, | ||
curX: 0, | ||
curY: 0 | ||
}, | ||
|
||
lazyLoadedList: [], | ||
|
||
// added for react | ||
initialized: false, | ||
edgeDragged: false, | ||
swiped: false, // used by swipeEvent. differentites between touch and swipe. | ||
trackStyle: {}, | ||
trackWidth: 0 | ||
|
||
// Removed | ||
// transformsEnabled: false, | ||
// $nextArrow: null, | ||
// $prevArrow: null, | ||
// $dots: null, | ||
// $list: null, | ||
// $slideTrack: null, | ||
// $slides: null, | ||
}; | ||
|
||
module.exports = initialState; |
Oops, something went wrong.