delatable item animation with native driver

This commit is contained in:
Roman Volosovskyi 2019-06-24 15:20:02 +03:00
parent 72d2faee14
commit 8ac0d6b92b
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
2 changed files with 8 additions and 3 deletions

View File

@ -309,7 +309,8 @@
swipe-pan-responder (responder/swipe-pan-responder offset-x styles/delete-button-width id swiped?)
swipe-pan-handler (responder/pan-handlers swipe-pan-responder)]
[react/view swipe-pan-handler
[react/animated-view {:style {:flex 1 :right offset-x}}
[react/animated-view {:style {:flex 1
:transform [{:translateX offset-x}]}}
body
[react/touchable-highlight {:style styles/delete-icon-highlight
:on-press on-delete}

View File

@ -13,7 +13,9 @@
(defn on-move [animated-offset-x end-offset-x swiped?]
(fn [_ gesture]
(let [to-value (get-updated-value gesture end-offset-x swiped?)]
(animation/start (animation/spring animated-offset-x {:toValue to-value})))))
(animation/start (animation/spring animated-offset-x
{:toValue (- to-value)
:useNativeDriver true})))))
(defn on-release [animated-offset-x end-offset-x chat-id swiped?]
(fn [_ gesture]
@ -21,7 +23,9 @@
should-open? (> updated-value (/ end-offset-x 2))
to-value (if should-open? end-offset-x 0)]
(re-frame/dispatch [:set-swipe-position :chats chat-id should-open?])
(animation/start (animation/spring animated-offset-x {:toValue to-value})))))
(animation/start (animation/spring animated-offset-x
{:toValue (- to-value)
:useNativeDriver true})))))
(defn swipe-pan-responder [animated-offset-x end-offset-x chat-id swiped?]
(.create (react/pan-responder)