Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-carousel

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-carousel - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

26

Carousel.js

@@ -7,2 +7,3 @@ var React = require('react/addons')

var MIN_MOVEMENT = 100
var MAX_TRANSITION_TIME = 350

@@ -12,3 +13,5 @@ var Carousel = React.createClass({

return {
prevIndex: 0,
currentIndex: 0,
itemWidths: Array(this.props.children.length),
itemStart: Array(this.props.children.length),

@@ -35,2 +38,3 @@ containerWidth: 0,

this.setState({
itemWidths: widths,
itemStart: startPos,

@@ -47,9 +51,12 @@ containerWidth: totalWidth

var index = this.state.currentIndex
if (x > 0) {
var imageMoveIndex = this.state.currentIndex
if (x < 0) {
if (index > 0) {
index = index - 1
imageMoveIndex = index
}
} else if (x < 0) {
} else if (x > 0) {
if (index < this.props.children.length - 1) {
index = index + 1
imageMoveIndex = imageMoveIndex
}

@@ -59,2 +66,3 @@ }

this.setState({
prevIndex: imageMoveIndex,
currentIndex: index,

@@ -70,3 +78,6 @@ delta: 0

maybeMoveImage: function (e, x) {
if (x > MIN_MOVEMENT) {
if (Math.abs(x) < MIN_MOVEMENT) {
this.setState({
delta: 0
})
return

@@ -98,2 +109,8 @@ }

var transitionTime = Math.min(
this.state.itemWidths[this.state.prevIndex] / 2,
MAX_TRANSITION_TIME
)
var transition = 'all ' + transitionTime + 'ms ease-out'
return React.DOM.div(

@@ -106,6 +123,7 @@ { className: 'carousel' },

onSwiped: this.maybeMoveImage,
className: cxContainer,
className: 'carousel-container',
ref: 'carouselContainer',
style: {
'-webkit-transform': 'translateX(' + delta + 'px)',
transition: this.state.delta === 0 ? transition : 'none',
width: this.state.containerWidth + 'px'

@@ -112,0 +130,0 @@ }

4

package.json
{
"name": "react-carousel",
"version": "1.0.1",
"version": "1.0.2",
"description": "A carousel written in react",

@@ -16,3 +16,3 @@ "main": "Carousel.js",

"react": "^0.11.2",
"react-swipeable": "^1.1.1"
"react-swipeable": "^1.1.3"
},

@@ -19,0 +19,0 @@ "author": "Josh Perez <josh@goatslacker.com>",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc