react-touch-carousel
Advanced tools
Comparing version 0.8.3 to 0.9.0
@@ -15,10 +15,4 @@ 'use strict'; | ||
var _Motion = require('react-motion/lib/Motion'); | ||
var _reactSpring = require('react-spring'); | ||
var _Motion2 = _interopRequireDefault(_Motion); | ||
var _spring = require('react-motion/lib/spring'); | ||
var _spring2 = _interopRequireDefault(_spring); | ||
var _utils = require('./utils'); | ||
@@ -58,5 +52,5 @@ | ||
precision: 0.001, | ||
tension: 200, | ||
friction: 25, | ||
moveScale: 1, | ||
stiffness: 200, | ||
damping: 25, | ||
onRest: function onRest() {}, | ||
@@ -109,3 +103,3 @@ onDragStart: function onDragStart() {}, | ||
var touchId = (0, _utils.getTouchId)(e); | ||
if (touchId !== _this.tracingTouchId) { | ||
if (touchId !== _this.tracingTouchId || !_this.touchMoves.length) { | ||
_this.touchMoves = [touchMove]; | ||
@@ -116,3 +110,3 @@ } | ||
var shouldIgnore = e.defaultPrevented; | ||
if (!shouldIgnore && _this.state.active && _this.touchMoves.length) { | ||
if (!shouldIgnore && _this.state.active) { | ||
if (_this.isMovingCross == null) { | ||
@@ -188,3 +182,3 @@ var _this$props2 = _this.props, | ||
var damping = _this.props.damping / 1e6; | ||
var friction = _this.props.friction / 1e6; | ||
var touchMoves = _this.touchMoves; | ||
@@ -200,3 +194,3 @@ | ||
var touchMoveVelocity = ((0, _utils.getTouchPosition)(e)[xy] - touchMoves[i][xy]) / duration; | ||
var momentumDistance = touchMoveVelocity * Math.abs(touchMoveVelocity) / damping / 2; | ||
var momentumDistance = touchMoveVelocity * Math.abs(touchMoveVelocity) / friction / 2; | ||
var cursor = _this.state.cursor; | ||
@@ -380,19 +374,19 @@ | ||
renderCard = _props2.renderCard, | ||
stiffness = _props2.stiffness, | ||
damping = _props2.damping, | ||
tension = _props2.tension, | ||
friction = _props2.friction, | ||
precision = _props2.precision, | ||
loop = _props2.loop, | ||
rest = _objectWithoutProperties(_props2, ['component', 'cardSize', 'cardCount', 'cardPadCount', 'renderCard', 'stiffness', 'damping', 'precision', 'loop']); | ||
rest = _objectWithoutProperties(_props2, ['component', 'cardSize', 'cardCount', 'cardPadCount', 'renderCard', 'tension', 'friction', 'precision', 'loop']); | ||
var padCount = loop ? cardPadCount : 0; | ||
var springConfig = { stiffness: stiffness, damping: damping, precision: precision }; | ||
var springConfig = { tension: tension, friction: friction, precision: precision }; | ||
var computedCursor = this.getComputedCursor(); | ||
return _react2.default.createElement( | ||
_Motion2.default, | ||
_reactSpring.Spring, | ||
{ | ||
defaultStyle: { cursor: computedCursor }, | ||
style: { | ||
cursor: this.shouldEnableSpring() ? (0, _spring2.default)(computedCursor, springConfig) : (0, _utils.precision)(computedCursor, precision) | ||
}, | ||
config: springConfig, | ||
from: { cursor: computedCursor }, | ||
immediate: !this.shouldEnableSpring(), | ||
to: { cursor: computedCursor }, | ||
onRest: this.onSpringRest | ||
@@ -399,0 +393,0 @@ }, |
@@ -8,3 +8,2 @@ "use strict"; | ||
exports.clamp = clamp; | ||
exports.precision = precision; | ||
exports.getTouchPosition = getTouchPosition; | ||
@@ -32,6 +31,2 @@ exports.getTouchId = getTouchId; | ||
function precision(n, p) { | ||
return Math.round(n / p) * p; | ||
} | ||
function getTouchPosition(e) { | ||
@@ -38,0 +33,0 @@ return { |
{ | ||
"name": "react-touch-carousel", | ||
"version": "0.8.3", | ||
"version": "0.9.0", | ||
"description": "Micro carousel framework for React.JS", | ||
@@ -49,4 +49,4 @@ "main": "lib/index.js", | ||
"raw-loader": "0.5.1", | ||
"react": "16.4.0", | ||
"react-dom": "16.4.0", | ||
"react": "16.6.3", | ||
"react-dom": "16.6.3", | ||
"standard": "11.0.1", | ||
@@ -61,3 +61,3 @@ "standard-loader": "^6.0.1", | ||
"dependencies": { | ||
"react-motion": "0.5.2" | ||
"react-spring": "^6.1.10" | ||
}, | ||
@@ -64,0 +64,0 @@ "standard": { |
34598
616
+ Addedreact-spring@^6.1.10
+ Added@babel/runtime@7.24.7(transitive)
+ Addedreact-spring@6.1.10(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
- Removedreact-motion@0.5.2
- Removedperformance-now@0.2.02.1.0(transitive)
- Removedraf@3.4.1(transitive)
- Removedreact@16.14.0(transitive)
- Removedreact-motion@0.5.2(transitive)