Created
July 8, 2018 20:04
-
-
Save bogoslavskiy/8e284c9e4748d585760c1c59665e475e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
maxActionAnimated = 88; // Location input height + padding (Bottom part) | |
actionAnimated = new Animated.Value(0); | |
getTransformWrapper() { | |
let byScroll = Animated.add( | |
Animated.multiply(this.clampedScroll, -1), | |
this.scrollY.interpolate({ // To negative | |
inputRange: [0, 1], | |
outputRange: [0, -1], | |
}).interpolate({ // Add bottom height part | |
inputRange: [-this.topPartHeight, 0], | |
outputRange: [0, this.minClamp], | |
extrapolate: 'clamp', | |
}) | |
); | |
return { | |
transform: [{ | |
translateY: Animated.add(byScroll, this.actionAnimated) | |
}] | |
}; | |
} | |
getTransformSearchBar() { | |
return { | |
transform: [{ | |
translateY: Animated.add( | |
this.actionAnimated.interpolate({ | |
inputRange: [0, this.maxActionAnimated], | |
outputRange: [0, -this.topPartHeight + this.arrowHeight], | |
extrapolate: 'clamp', | |
}), | |
this.scrollY.interpolate({ | |
inputRange: [0, this.topPartHeight], | |
outputRange: [0, this.topPartHeight - this.arrowHeight], | |
extrapolate: 'clamp', | |
})) | |
}] | |
}; | |
} | |
getOpacitySearchBar() { | |
return { | |
opacity: this.clampedScroll.interpolate({ | |
inputRange: [this.topPartHeight, this.maxClamp], | |
outputRange: [1, 0], | |
extrapolate: 'clamp', | |
}) | |
}; | |
} | |
getOpacityLocationInput() { | |
return { | |
opacity: Animated.add( | |
this.actionAnimated.interpolate({ | |
inputRange: [0, this.maxActionAnimated], | |
outputRange: [0, 1], | |
extrapolate: 'clamp', | |
}), | |
this.scrollY.interpolate({ | |
inputRange: [0, this.topPartHeight], | |
outputRange: [1, 0], | |
extrapolate: 'clamp', | |
}) | |
) | |
}; | |
} | |
getArrowMinimizeStyle() { | |
return { | |
transform: [{ | |
translateY: Animated.add( | |
this.actionAnimated.interpolate({ | |
inputRange: [0, this.maxActionAnimated], | |
outputRange: [0, -this.topPartHeight], | |
extrapolate: 'clamp', | |
}), | |
this.scrollY.interpolate({ | |
inputRange: [0, this.topPartHeight], | |
outputRange: [0, this.topPartHeight], | |
extrapolate: 'clamp', | |
}) | |
) | |
}], | |
opacity: Animated.add( | |
this.actionAnimated.interpolate({ | |
inputRange: [0, this.maxActionAnimated], | |
outputRange: [0, 1], | |
extrapolate: 'clamp', | |
}), | |
this.scrollY.interpolate({ | |
inputRange: [0, this.topPartHeight], | |
outputRange: [1, 0], | |
extrapolate: 'clamp', | |
}) | |
) | |
}; | |
} | |
getStyleSuggestion() { | |
let scroll = this.scrollY.interpolate({ // To negative | |
inputRange: [0, 1], | |
outputRange: [0, -1], | |
}); | |
return { | |
opacity: Animated.add( | |
this.actionAnimated.interpolate({ | |
inputRange: [0, this.maxActionAnimated], | |
outputRange: [0, 1], | |
extrapolate: 'clamp', | |
}), | |
scroll.interpolate({ | |
inputRange: [-this.topPartHeight, 0], | |
outputRange: [0, 1], | |
extrapolate: 'clamp' | |
}) | |
), | |
transform: [{ | |
translateY: Animated.add( | |
this.actionAnimated.interpolate({ | |
inputRange: [0, this.maxActionAnimated], | |
outputRange: [0, this.topPartHeight], | |
extrapolate: 'clamp', | |
}), | |
scroll.interpolate({ | |
inputRange: [-this.topPartHeight, 0], | |
outputRange: [this.topPartHeight, this.wrapperHeight], | |
extrapolate: 'clamp' | |
}) | |
) | |
}] | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment