Skip to content

Instantly share code, notes, and snippets.

@ruucm-working
Created May 22, 2019 19:53
Show Gist options
  • Save ruucm-working/73e05683475f8e1dc49063977d250c15 to your computer and use it in GitHub Desktop.
Save ruucm-working/73e05683475f8e1dc49063977d250c15 to your computer and use it in GitHub Desktop.
--- a/tinder-swipe.framerfx/code/App.tsx
+++ b/tinder-swipe.framerfx/code/App.tsx
@@ -1,4 +1,4 @@
-import { Override, useAnimation, useMotionValue } from 'framer'
+import { Override, useAnimation, useMotionValue, transform } from 'framer'
// Override Docs: https://framer.com/docs/overrides
window.log = console.log
@@ -20,10 +20,27 @@ export function Card(): Override {
x: dragX,
y: dragY,
animate: anim,
- onDragEnd(event, info) {
+ onDrag(event, info) {
var dragAmount = info.point.x
log('dragAmount', dragAmount)
+ // Buttons Animation
+ likeButtonAnim.start({
+ opacity: transform(dragAmount, [30, 150], [0, 1]),
+ transition: {
+ duration: 0,
+ },
+ })
+ nopeButtonAnim.start({
+ opacity: transform(dragAmount, [-30, -150], [0, 1]),
+ transition: {
+ duration: 0,
+ },
+ })
+ },
+ onDragEnd(event, info) {
+ var dragAmount = info.point.x
+
if (dragAmount > 150) {
// swipe card right side
dragX.stop()
@@ -45,6 +62,36 @@ export function Card(): Override {
},
})
}
+
+ // Buttons Animation
+ likeButtonAnim.start({
+ opacity: 0,
+ })
+ nopeButtonAnim.start({
+ opacity: 0,
+ })
+ },
+ }
+}
+
+var likeButtonAnim
+export function LikeButton(): Override {
+ likeButtonAnim = useAnimation()
+ return {
+ initial: {
+ opacity: 0,
+ },
+ animate: likeButtonAnim,
+ }
+}
+
+var nopeButtonAnim
+export function NopeButton(): Override {
+ nopeButtonAnim = useAnimation()
+ return {
+ initial: {
+ opacity: 0,
},
+ animate: nopeButtonAnim,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment