[#16322] Add carousel tap gesture
* Add tap gesture to carousel * Updates uses of carousel * Gestures only detected on carousel content instead of full screen on Android
This commit is contained in:
parent
5dcd64c478
commit
e2b7a299b4
|
@ -79,7 +79,7 @@
|
||||||
:paused? paused?
|
:paused? paused?
|
||||||
:header-text header-text
|
:header-text header-text
|
||||||
:header-background true
|
:header-background true
|
||||||
:swipeable? true
|
:gesture :swipeable
|
||||||
:background [background-image (* 4 window-width)]}]
|
:background [background-image (* 4 window-width)]}]
|
||||||
(when dark-overlay?
|
(when dark-overlay?
|
||||||
[blur/view
|
[blur/view
|
||||||
|
|
|
@ -95,9 +95,7 @@
|
||||||
|
|
||||||
(defn drag-gesture
|
(defn drag-gesture
|
||||||
[progress paused]
|
[progress paused]
|
||||||
(->
|
(-> (gesture/gesture-pan)
|
||||||
(gesture/gesture-pan)
|
|
||||||
(gesture/enabled true)
|
|
||||||
(gesture/max-pointers 1)
|
(gesture/max-pointers 1)
|
||||||
(gesture/on-finalize
|
(gesture/on-finalize
|
||||||
(fn [event]
|
(fn [event]
|
||||||
|
@ -108,6 +106,11 @@
|
||||||
(when previous?
|
(when previous?
|
||||||
(update-progress progress paused (get-previous-progress progress))))))))
|
(update-progress progress paused (get-previous-progress progress))))))))
|
||||||
|
|
||||||
|
(defn tap-gesture
|
||||||
|
[progress paused]
|
||||||
|
(-> (gesture/gesture-tap)
|
||||||
|
(gesture/on-end #(update-progress progress paused (get-next-progress progress)))))
|
||||||
|
|
||||||
(defn carousel-left-position
|
(defn carousel-left-position
|
||||||
[window-width animate? progress]
|
[window-width animate? progress]
|
||||||
(if animate?
|
(if animate?
|
||||||
|
|
|
@ -63,14 +63,9 @@
|
||||||
|
|
||||||
(defn carousel-container
|
(defn carousel-container
|
||||||
[left animate?]
|
[left animate?]
|
||||||
(let [normal-style {:position :absolute
|
(cond->> {:position :absolute
|
||||||
:right 0
|
:right 0
|
||||||
:top 0
|
:top 0
|
||||||
:bottom 0
|
|
||||||
:flex-direction :row
|
:flex-direction :row
|
||||||
:left left}]
|
:left left}
|
||||||
(if animate?
|
animate? (reanimated/apply-animations-to-style {:left left})))
|
||||||
(reanimated/apply-animations-to-style
|
|
||||||
{:left left}
|
|
||||||
normal-style)
|
|
||||||
normal-style)))
|
|
||||||
|
|
|
@ -50,15 +50,18 @@
|
||||||
:progress-bar-width progress-bar-width}]]))
|
:progress-bar-width progress-bar-width}]]))
|
||||||
|
|
||||||
(defn f-view
|
(defn f-view
|
||||||
[{:keys [animate? progress paused? header-text background header-background swipeable?]}]
|
[{:keys [animate? progress paused? header-text background header-background gesture]}]
|
||||||
(let [window-width (rf/sub [:dimensions/window-width])
|
(let [window-width (rf/sub [:dimensions/window-width])
|
||||||
status-bar-height (:status-bar-height @navigation/constants)
|
status-bar-height (:status-bar-height @navigation/constants)
|
||||||
progress-bar-width (- window-width 40)
|
progress-bar-width (- window-width 40)
|
||||||
carousel-left (animation/carousel-left-position window-width animate? progress)
|
carousel-left (animation/carousel-left-position window-width animate? progress)
|
||||||
container-view (if animate? reanimated/view rn/view)]
|
container-view (if animate? reanimated/view rn/view)
|
||||||
|
identified-gesture (case gesture
|
||||||
|
:swipeable (animation/drag-gesture progress paused?)
|
||||||
|
:tappable (animation/tap-gesture progress paused?)
|
||||||
|
nil)]
|
||||||
[:<>
|
[:<>
|
||||||
[gesture/gesture-detector
|
[gesture/gesture-detector {:gesture identified-gesture}
|
||||||
{:gesture (when swipeable? (animation/drag-gesture progress paused?))}
|
|
||||||
[container-view {:style (style/carousel-container carousel-left animate?)}
|
[container-view {:style (style/carousel-container carousel-left animate?)}
|
||||||
(for [index (range 2)]
|
(for [index (range 2)]
|
||||||
^{:key index}
|
^{:key index}
|
||||||
|
@ -68,7 +71,7 @@
|
||||||
:index index
|
:index index
|
||||||
:header-text header-text
|
:header-text header-text
|
||||||
:header-background header-background}
|
:header-background header-background}
|
||||||
(when background background)])]]
|
background])]]
|
||||||
[rn/view
|
[rn/view
|
||||||
{:style (style/progress-bar-container
|
{:style (style/progress-bar-container
|
||||||
progress-bar-width
|
progress-bar-width
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
{:animate? true
|
{:animate? true
|
||||||
:progress progress
|
:progress progress
|
||||||
:paused? paused?
|
:paused? paused?
|
||||||
:swipeable? false
|
:gesture :tappable
|
||||||
:header-text header-text}]
|
:header-text header-text}]
|
||||||
[rn/view {:style style/content-container}
|
[rn/view {:style style/content-container}
|
||||||
[quo/profile-card
|
[quo/profile-card
|
||||||
|
|
Loading…
Reference in New Issue