git ssb

1+

Daan Patchwork / manyverse



Commit 800c454b96d1ed7526c57b56ae1755a36194cced

dx: fix the sticky header behavior

Andre Staltz committed on 2/4/2020, 11:53:17 AM
Parent: fa786003db504457620bb7841d4f42ba314b4466

Files changed

src/frontend/screens/central/model.tschanged
src/frontend/screens/central/top-bar/index.tschanged
src/frontend/screens/central/model.tsView
@@ -137,10 +137,8 @@
137137
138138 const changeTabReducer$ = actions.changeTab$.map(
139139 nextTab =>
140140 function changeTabReducer(prev: State): State {
141- prev.scrollHeaderBy.stopAnimation();
142- prev.scrollHeaderBy.setValue(0);
143141 return {...prev, currentTab: nextTab};
144142 },
145143 );
146144
src/frontend/screens/central/top-bar/index.tsView
@@ -83,19 +83,23 @@
8383 return '';
8484 }
8585
8686 function view(state$: Stream<State>) {
87- let translateY: Animated.AnimatedMultiplication | null = null;
87+ const fixAtTop = new Animated.Value(0);
88+ let hideWhenScrolling: Animated.AnimatedMultiplication | null = null;
8889
8990 return state$.map(state => {
9091 // Avoid re-instantiating a new animated value on every stream emission
91- if (!translateY) {
92- translateY = Animated.multiply(
92+ if (!hideWhenScrolling) {
93+ hideWhenScrolling = Animated.multiply(
9394 Animated.diffClamp(state.scrollHeaderBy, 0, Dimensions.toolbarHeight),
9495 -1,
9596 );
9697 }
9798
99+ const translateY =
100+ state.currentTab === 'public' ? hideWhenScrolling : fixAtTop;
101+
98102 return h(
99103 Animated.View,
100104 {style: [styles.container, {transform: [{translateY}]}]},
101105 [

Built with git-ssb-web