git.iko.soy/rowtype-yoga/ry-blocks
on main help sign in
Segmented
commita05b1888589ffeec5442931556d01de20e24de4f authorMark Eibes <mark.eibes@zalando.de> dateWed 6 Jan 2021, 19:57 (6 years ago) parent46f147a
2 files changed+8−12
src/Yoga/Block/Atom/Segmented/Style.purs−1 src/Yoga/Block/Atom/Segmented/View/ActiveIndicator.purs+8−11
src/Yoga/Block/Atom/Segmented/Style.purs−1
@@ -47,7 +47,6 @@ activeElementWrapper =
4747 { position: relative
4848 , boxSizing: borderBox
4949 , width: str "0"
50− , height: str "100%"
5150 , overflow: visible
5251 , padding: _0
5352 , margin: _0
src/Yoga/Block/Atom/Segmented/View/ActiveIndicator.purs+8−11
@@ -80,10 +80,9 @@ component =
8080 { className: "ry-active-segmented-element-wrapper"
8181 , css: Style.activeElementWrapper
8282 , children:
83− [ Emotion.elementKeyed Motion.div
83+ [ Emotion.element Motion.div
8484 { css: Style.activeElement
8585 , layout: Motion.layout true
86− , key: show (props.windowSize /\ scrollX /\ scrollY) -- to force rerender
8786 , custom: Motion.customProp (({ childRefs: props.activeItemRefs, scrollX, scrollY }) ∷ Custom)
8887 , variants
8988 , className: "ry-active-segmented-element"
@@ -96,6 +95,7 @@ component =
9695 { left: activeLeft
9796 , width: activeWidth
9897 }
98+ , whileTap: Motion.whileTap $ css { scaleY: 0.8, scaleX: 0.95, y: -1.0 }
9999 , onDragStart:
100100 Motion.onDragStart \_ pi -> do
101101 maybeBbox <- getBoundingBoxFromRef (TwoOrMore.head props.activeItemRefs)
@@ -110,22 +110,19 @@ component =
110110 , onDragEnd:
111111 Motion.onDragEnd \_ pi -> do
112112 let
113− x =
114− maybeDragX
115− # fromMaybe' \_ -> unsafeCrashWith "no x"
113+ x = maybeDragX # fromMaybe' \_ -> unsafeCrashWith "no x"
116114 newIdx =
117115 findOverlapping
118116 props.activeItemIndex
119117 animationVariants
120118 x
121− v =
122− animationVariants TwoOrMore.!! newIdx
119+ v = animationVariants TwoOrMore.!! newIdx
123120 # fromMaybe' \_ -> unsafeCrashWith "omg"
124− setDragX Nothing
125121 activeLeft # MotionValue.set v.left
126122 activeWidth # MotionValue.set v.width
127123 props.updateActiveIndex newIdx
128− , dragConstraints: Motion.dragConstraints { left: 0, right: 0 }
124+ setDragX Nothing
125+ , dragConstraints: Motion.dragConstraints { left: 0, right: 0, top: 0, bottom: 0 }
129126 , dragElastic: Motion.dragElastic false
130127 , transition:
131128 Motion.transition
@@ -198,8 +195,8 @@ handleDrag { x, activeItemIndex, animationVariants } = do
198195 else
199196 closestVariant /\ baseVariant
200197 -- Total
201− let rangeStart = smaller.left + (smaller.width / 2.0)
202− let rangeEnd = greater.left + (greater.width / 2.0)
198+ let rangeStart = smaller.left + smaller.width / 2.0
199+ let rangeEnd = greater.left + greater.width / 2.0
203200 let range = rangeEnd - rangeStart
204201 let ratio = ((x - rangeStart) / range)
205202 let interpolatedWidth = (greater.width * ratio) + smaller.width * (1.0 - ratio)