Created
May 22, 2019 19:52
-
-
Save ruucm-working/1fccdf77d799b6dc07f4ccfeb7659648 to your computer and use it in GitHub Desktop.
This file contains 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
--- a/tinder-swipe.framerfx/code/App.tsx | |
+++ b/tinder-swipe.framerfx/code/App.tsx | |
@@ -1,8 +1,10 @@ | |
-import { Override } from 'framer' | |
+import { Override, useAnimation } from 'framer' | |
// Override Docs: https://framer.com/docs/overrides | |
+window.log = console.log | |
export function Card(): Override { | |
+ const anim = useAnimation() | |
return { | |
drag: true, | |
dragConstraints: { | |
@@ -12,5 +14,30 @@ export function Card(): Override { | |
right: 0, | |
}, | |
dragElastic: 1, | |
+ animate: anim, | |
+ onDragEnd(event, info) { | |
+ // log('event', event) | |
+ // log('info', info) | |
+ var dragAmount = info.point.x | |
+ log('dragAmount', dragAmount) | |
+ | |
+ if (dragAmount > 150) { | |
+ // swipe card right side | |
+ anim.start({ | |
+ left: 500, | |
+ transition: { | |
+ duration: 1, | |
+ }, | |
+ }) | |
+ } else if (dragAmount < -150) { | |
+ // swipe card right side | |
+ anim.start({ | |
+ right: 500, | |
+ transition: { | |
+ duration: 1, | |
+ }, | |
+ }) | |
+ } | |
+ }, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment