delatable item animation with native driver
This commit is contained in:
parent
72d2faee14
commit
8ac0d6b92b
|
@ -309,7 +309,8 @@
|
||||||
swipe-pan-responder (responder/swipe-pan-responder offset-x styles/delete-button-width id swiped?)
|
swipe-pan-responder (responder/swipe-pan-responder offset-x styles/delete-button-width id swiped?)
|
||||||
swipe-pan-handler (responder/pan-handlers swipe-pan-responder)]
|
swipe-pan-handler (responder/pan-handlers swipe-pan-responder)]
|
||||||
[react/view swipe-pan-handler
|
[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
|
body
|
||||||
[react/touchable-highlight {:style styles/delete-icon-highlight
|
[react/touchable-highlight {:style styles/delete-icon-highlight
|
||||||
:on-press on-delete}
|
:on-press on-delete}
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
(defn on-move [animated-offset-x end-offset-x swiped?]
|
(defn on-move [animated-offset-x end-offset-x swiped?]
|
||||||
(fn [_ gesture]
|
(fn [_ gesture]
|
||||||
(let [to-value (get-updated-value gesture end-offset-x swiped?)]
|
(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?]
|
(defn on-release [animated-offset-x end-offset-x chat-id swiped?]
|
||||||
(fn [_ gesture]
|
(fn [_ gesture]
|
||||||
|
@ -21,7 +23,9 @@
|
||||||
should-open? (> updated-value (/ end-offset-x 2))
|
should-open? (> updated-value (/ end-offset-x 2))
|
||||||
to-value (if should-open? end-offset-x 0)]
|
to-value (if should-open? end-offset-x 0)]
|
||||||
(re-frame/dispatch [:set-swipe-position :chats chat-id should-open?])
|
(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?]
|
(defn swipe-pan-responder [animated-offset-x end-offset-x chat-id swiped?]
|
||||||
(.create (react/pan-responder)
|
(.create (react/pan-responder)
|
||||||
|
|
Loading…
Reference in New Issue