react-native-ring-picker
Advanced tools
Comparing version 1.2.3 to 1.2.4
{ | ||
"name": "react-native-ring-picker", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "React Native Ring wheel Picker Navigator with complex animations by dragging", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -127,3 +127,3 @@ import React from "react"; | ||
getCurrentSnappedMiddleIcon(icons) { | ||
return icons.filter((icon) => icon.index === 0)[0].id; | ||
return icons.filter((icon) => icon.index === 0)[0]; | ||
} | ||
@@ -182,3 +182,3 @@ | ||
minDistanceToVerticalAxis = distanceToXAxis; | ||
currentSnappedIcon = icon.id; | ||
currentSnappedIcon = icon; | ||
} | ||
@@ -209,6 +209,9 @@ }); | ||
updateMinimalDistanceExponentialDeflection(minDistanceToVerticalAxis, minDistanceToHorizontalAxis, currentSnappedIcon) { | ||
const id = currentSnappedIcon.id; | ||
const index = currentSnappedIcon.index; | ||
let minV = minDistanceToVerticalAxis; | ||
let minH = minDistanceToHorizontalAxis; | ||
let currentAngle = (270 + this.state.CURRENT_ICON_SHIFT + (this.INDEX_EXTRACTORS[currentSnappedIcon] || 0) + (this.state.icons.filter((icon) => icon.id === currentSnappedIcon)[0].index * this.ICON_POSITION_ANGLE)); | ||
let currentAngle = (270 + this.state.CURRENT_ICON_SHIFT + (this.INDEX_EXTRACTORS[id] || 0) + (index * this.ICON_POSITION_ANGLE)); | ||
@@ -331,3 +334,3 @@ if (currentAngle < 255 || currentAngle > 285) { | ||
goToCurrentFocusedPage = () => { | ||
this.state.currentSnappedIcon && this.props.onPress(this.state.currentSnappedIcon); | ||
this.state.currentSnappedIcon && this.props.onPress(this.state.currentSnappedIcon.id); | ||
}; | ||
@@ -478,4 +481,4 @@ | ||
calculateIconCurrentPosition(key) { | ||
let currentIconAngle = this.calculateCurrentIconAngle(key); | ||
calculateIconCurrentPosition(icon) { | ||
let currentIconAngle = this.calculateCurrentIconAngle(icon); | ||
// the Y coordinate where the center of the circle is higher than the coordinates of Icons, this is actually similar {+X:-Y} section of coordinate net | ||
@@ -508,12 +511,15 @@ // and INVERTED, this is basically if we'd have an upside-down screen always | ||
calculateCurrentIconAngle(key) { | ||
if (!this.INDEX_EXTRACTORS[key]) { | ||
this.INDEX_EXTRACTORS[key] = 0; | ||
calculateCurrentIconAngle(icon) { | ||
const id = icon.id; | ||
const index = icon.index; | ||
if (!this.INDEX_EXTRACTORS[id]) { | ||
this.INDEX_EXTRACTORS[id] = 0; | ||
} | ||
let currentAngle = (270 + this.state.CURRENT_ICON_SHIFT + this.INDEX_EXTRACTORS[key] + (this.state.icons.filter((icon) => icon.id === key)[0].index * this.ICON_POSITION_ANGLE)); | ||
let currentAngle = (270 + this.state.CURRENT_ICON_SHIFT + this.INDEX_EXTRACTORS[id] + (index * this.ICON_POSITION_ANGLE)); | ||
if (currentAngle < 270 - this.GIRTH_ANGLE / 2) { | ||
this.hideIconWhileMovingBehindCircle(key); | ||
this.INDEX_EXTRACTORS[key] += this.GIRTH_ANGLE; | ||
this.hideIconWhileMovingBehindCircle(id); | ||
this.INDEX_EXTRACTORS[id] += this.GIRTH_ANGLE; | ||
return currentAngle + this.GIRTH_ANGLE; | ||
@@ -523,4 +529,4 @@ } | ||
if (currentAngle > 270 + this.GIRTH_ANGLE / 2) { | ||
this.hideIconWhileMovingBehindCircle(key); | ||
this.INDEX_EXTRACTORS[key] -= this.GIRTH_ANGLE; | ||
this.hideIconWhileMovingBehindCircle(id); | ||
this.INDEX_EXTRACTORS[id] -= this.GIRTH_ANGLE; | ||
return currentAngle - this.GIRTH_ANGLE; | ||
@@ -542,3 +548,3 @@ } | ||
this.state.icons.forEach((icon) => { | ||
let coordinates = this.calculateIconCurrentPosition(icon.id); | ||
let coordinates = this.calculateIconCurrentPosition(icon); | ||
@@ -545,0 +551,0 @@ Animated.spring(icon.position, { |
75103
780