Skip to content

Commit

Permalink
fix: re-animated v3 related cleanup (Extrapolate)
Browse files Browse the repository at this point in the history
  • Loading branch information
siddarthkay committed Sep 9, 2023
1 parent 6b465cf commit 5dbbb08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 69 deletions.
63 changes: 7 additions & 56 deletions src/quo/animated.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns quo.animated
(:refer-clojure :exclude [abs set delay divide])
(:require ["react-native-reanimated" :default animated :refer
(clockRunning Easing)]
(clockRunning Easing Extrapolate)]
["react-native-redash" :as redash]
[oops.core :refer [ocall oget]]
[quo.gesture-handler :as gh]
Expand Down Expand Up @@ -85,20 +85,12 @@

(def clock-running clockRunning)

;;;; commented out to upgrade react-native-reanimated to v3 and react-native to 0.72
;;;;; TODO: replace this with an updated implementation
;;;TypeError: undefined is not an object (evaluating
;;;'shadow.js.shim.module$react_native_reanimated.EasingNode.bezier')
(def bezier (.-bezier ^js Easing))

;;;ERROR TypeError: undefined is not an object (evaluating
;;;'shadow.js.shim.module$react_native_reanimated.EasingNode.linear')
;(def linear (.-linear ^js EasingNode))
(def linear (.-linear ^js Easing))


;;; They depend on bezier and linear
(def easings
{; :linear linear
{:linear linear
:ease-in (bezier 0.42 0 1 1)
:ease-out (bezier 0 0 0.58 1)
:ease-in-out (bezier 0.42 0 0.58 1)
Expand Down Expand Up @@ -203,16 +195,13 @@
(clj->js opts)
(clj->js config)))

;;;; commented out to upgrade react-native-reanimated to v3 and react-native to 0.72
;;;;; TODO: replace this with an updated implementation
;;;ERROR Error: Oops, Missing expected object key 'log'
;(def extrapolate {:clamp (oget animated "Extrapolate" "CLAMP")})
;
(def extrapolate {:clamp (oget Extrapolate "CLAMP")})

;;; utilities
;

(def clamp (oget redash "clamp"))
(def diff-clamp (.-diffClamp ^js redash))
;

(defn with-spring
[config]
(ocall redash "withSpring" (clj->js config)))
Expand Down Expand Up @@ -282,41 +271,3 @@
(defn snap-point
[v velocity snap-points]
(.snapPoint ^js redash v velocity (to-array snap-points)))

;;;; commented out to upgrade react-native-reanimated to v3 and react-native to 0.72
;;;;; TODO: replace this with an updated implementation
;(defn with-easing
; [{v :value
; :keys [snap-points velocity offset state easing duration
; animation-over]
; :or {duration 250
; animation-over (value 1)
; easing (:ease-out easings)}}]
; (let [position (value 0)
; c (clock)
; interrupted (and* (eq state (:began gh/states))
; (clock-running c))
; vel (multiply velocity 1.5)
; to (snap-point position vel snap-points)
; finish-animation [(set offset position)
; (stop-clock c)
; (set animation-over 1)]]
; (block
; [(cond* interrupted finish-animation)
; (cond* animation-over
; (set position offset))
; (cond* (neq state (:end gh/states))
; [(set animation-over 0)
; (set position (add offset v))])
; (cond* (and* (eq state (:end gh/states))
; (not* animation-over))
; [(set position
; (re-timing
; {:clock c
; :easing easing
; :duration duration
; :from position
; :to to}))
; (cond* (not* (clock-running c))
; finish-animation)])
; position])))
16 changes: 3 additions & 13 deletions src/quo/components/animated_header.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,14 @@
value
{:inputRange [0 offset]
:outputRange [0 4]
;commented out to upgrade react-native-reanimated to v3 and react-native to 0.72
;TODO: replace this with an updated implementation
; :extrapolate (:clamp animated/extrapolate)
})})
:extrapolate (:clamp animated/extrapolate)})})
(when (and offset platform/ios?)
{:z-index 2
:shadow-opacity (animated/interpolate
value
{:inputRange [0 offset]
:outputRange [0 1]
;commented out to upgrade react-native-reanimated to v3 and react-native to 0.72
;TODO: replace this with an updated implementation
; :extrapolate (:clamp animated/extrapolate)
})
:extrapolate (:clamp animated/extrapolate)})
:shadow-radius 16
:shadow-color (:shadow-01 @colors/theme)
:shadow-offset {:width 0 :height 4}})))
Expand All @@ -47,11 +41,7 @@
animation (animated/with-timing-transition
animation-value
{:duration 250
;commented out to upgrade react-native-reanimated to v3 and react-native to
;0.72
;TODO: replace this with an updated implementation
; :easing (:ease-in animated/easings)
})
:easing (:ease-in animated/easings)})
on-scroll (animated/on-scroll {:y y})
layout (reagent/atom {})
offset (reagent/atom 0)
Expand Down

0 comments on commit 5dbbb08

Please sign in to comment.