nuka-carousel
Advanced tools
Comparing version 0.0.8 to 0.0.9
{ | ||
"name": "nuka-carousel", | ||
"main": "index.js", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"homepage": "https://github.com/kenwheeler/nuka-carousel", | ||
@@ -6,0 +6,0 @@ "authors": [ |
@@ -44,2 +44,15 @@ 'use strict'; | ||
var removeEvent = function removeEvent(elem, type, eventHandle) { | ||
if (elem == null || typeof elem === 'undefined') { | ||
return; | ||
} | ||
if (elem.removeEventListener) { | ||
elem.removeEventListener(type, eventHandle, false); | ||
} else if (elem.detachEvent) { | ||
elem.detachEvent('on' + type, eventHandle); | ||
} else { | ||
elem['on' + type] = null; | ||
} | ||
}; | ||
var Carousel = _React2['default'].createClass({ | ||
@@ -56,6 +69,5 @@ displayName: 'Carousel', | ||
dragging: _React2['default'].PropTypes.bool, | ||
framePadding: _React2['default'].PropTypes.string, | ||
easing: _React2['default'].PropTypes.string, | ||
edgeEasing: _React2['default'].PropTypes.string, | ||
padding: _React2['default'].PropTypes.string, | ||
framePadding: _React2['default'].PropTypes.string, | ||
slidesToShow: _React2['default'].PropTypes.number, | ||
@@ -102,2 +114,6 @@ slidesToScroll: _React2['default'].PropTypes.number, | ||
componentWillUnmount: function componentWillUnmount() { | ||
this.unbindEvents(); | ||
}, | ||
render: function render() { | ||
@@ -108,3 +124,3 @@ var self = this; | ||
'div', | ||
{ className: 'slider', ref: 'slider', style: _assign2['default'](this.getSliderStyles(), this.props.style || {}) }, | ||
{ className: ['slider', this.props.className || ''].join(' '), ref: 'slider', style: _assign2['default'](this.getSliderStyles(), this.props.style || {}) }, | ||
_React2['default'].createElement( | ||
@@ -115,3 +131,4 @@ 'div', | ||
style: this.getFrameStyles() | ||
}, this.getTouchEvents(), this.getMouseEvents()), | ||
}, this.getTouchEvents(), this.getMouseEvents(), { | ||
onClick: this.handleClick }), | ||
_React2['default'].createElement( | ||
@@ -231,5 +248,2 @@ 'ul', | ||
}, | ||
onClick: function onClick(e) { | ||
self.handleClick(e); | ||
}, | ||
onMouseUp: function onMouseUp(e) { | ||
@@ -399,10 +413,20 @@ if (!self.state.dragging) { | ||
var self = this; | ||
addEvent(window, 'resize', function () { | ||
self.setDimensions(); | ||
}); | ||
addEvent(document, 'readystatechange', function () { | ||
self.setDimensions(); | ||
}); | ||
addEvent(window, 'resize', self.onResize); | ||
addEvent(document, 'readystatechange', self.onReadyStateChange); | ||
}, | ||
onResize: function onResize() { | ||
this.setDimensions(); | ||
}, | ||
onReadyStateChange: function onReadyStateChange(event) { | ||
this.setDimensions(); | ||
}, | ||
unbindEvents: function unbindEvents() { | ||
var self = this; | ||
removeEvent(window, 'resize', self.onResize); | ||
removeEvent(document, 'readystatechange', self.onReadyStateChange); | ||
}, | ||
formatChildren: function formatChildren(children) { | ||
@@ -409,0 +433,0 @@ var self = this; |
{ | ||
"name": "nuka-carousel", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Pure React Carousel", | ||
@@ -30,4 +30,7 @@ "main": "index.js", | ||
"gulp-webpack": "^1.3.0", | ||
"istanbul": "^0.3.13", | ||
"istanbul-instrumenter-loader": "^0.1.2", | ||
"karma": "~0.12.21", | ||
"karma-chrome-launcher": "~0.1.4", | ||
"karma-coverage": "^0.3.1", | ||
"karma-firefox-launcher": "~0.1.3", | ||
@@ -34,0 +37,0 @@ "karma-mocha": "^0.1.10", |
@@ -23,2 +23,15 @@ 'use strict'; | ||
const removeEvent = function(elem, type, eventHandle) { | ||
if (elem == null || typeof (elem) === 'undefined') { | ||
return; | ||
} | ||
if (elem.removeEventListener) { | ||
elem.removeEventListener(type, eventHandle, false); | ||
} else if (elem.detachEvent) { | ||
elem.detachEvent('on' + type, eventHandle); | ||
} else { | ||
elem['on'+type] = null; | ||
} | ||
}; | ||
const Carousel = React.createClass({ | ||
@@ -35,6 +48,5 @@ displayName: 'Carousel', | ||
dragging: React.PropTypes.bool, | ||
framePadding: React.PropTypes.string, | ||
easing: React.PropTypes.string, | ||
edgeEasing: React.PropTypes.string, | ||
padding: React.PropTypes.string, | ||
framePadding: React.PropTypes.string, | ||
slidesToShow: React.PropTypes.number, | ||
@@ -84,2 +96,6 @@ slidesToScroll: React.PropTypes.number, | ||
componentWillUnmount() { | ||
this.unbindEvents(); | ||
}, | ||
render() { | ||
@@ -89,3 +105,3 @@ var self = this; | ||
return ( | ||
<div className='slider' ref="slider" style={assign(this.getSliderStyles(), this.props.style || {})}> | ||
<div className={['slider', this.props.className || ''].join(' ')} ref="slider" style={assign(this.getSliderStyles(), this.props.style || {})}> | ||
<div className="slider-frame" | ||
@@ -95,3 +111,4 @@ ref="frame" | ||
{...this.getTouchEvents()} | ||
{...this.getMouseEvents()}> | ||
{...this.getMouseEvents()} | ||
onClick={this.handleClick}> | ||
<ul className="slider-list" ref="list" style={this.getListStyles()}> | ||
@@ -222,5 +239,2 @@ {children} | ||
}, | ||
onClick(e) { | ||
self.handleClick(e); | ||
}, | ||
onMouseUp(e) { | ||
@@ -388,10 +402,20 @@ if (!self.state.dragging) { | ||
var self = this; | ||
addEvent(window, 'resize', function() { | ||
self.setDimensions(); | ||
}); | ||
addEvent(document, 'readystatechange', function() { | ||
self.setDimensions(); | ||
}); | ||
addEvent(window, 'resize', self.onResize); | ||
addEvent(document, 'readystatechange', self.onReadyStateChange); | ||
}, | ||
onResize() { | ||
this.setDimensions(); | ||
}, | ||
onReadyStateChange(event) { | ||
this.setDimensions(); | ||
}, | ||
unbindEvents() { | ||
var self = this; | ||
removeEvent(window, 'resize', self.onResize); | ||
removeEvent(document, 'readystatechange', self.onReadyStateChange); | ||
}, | ||
formatChildren(children) { | ||
@@ -398,0 +422,0 @@ var self = this; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73303
20
2084
37