@hero-design/rn 8.59.0 → 8.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +6 -0
- package/es/index.js +183 -102
- package/lib/index.js +183 -102
- package/package.json +1 -1
- package/src/components/AnimatedScroller/AnimatedFAB.tsx +99 -49
- package/src/components/AnimatedScroller/AnimatedScrollable.tsx +18 -3
- package/src/components/AnimatedScroller/__tests__/ScrollablesWithFAB.spec.tsx +30 -9
- package/src/components/AnimatedScroller/__tests__/__snapshots__/ScrollablesWithFAB.spec.tsx.snap +474 -447
- package/src/components/FAB/ActionGroup/ActionItem.tsx +3 -1
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +216 -211
- package/src/components/FAB/ActionGroup/index.tsx +34 -28
- package/src/components/FAB/FAB.tsx +102 -41
- package/src/components/FAB/StyledFAB.tsx +10 -8
- package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +34 -38
- package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +191 -170
- package/types/components/AnimatedScroller/AnimatedFAB.d.ts +3 -1
- package/types/components/AnimatedScroller/AnimatedScrollable.d.ts +1 -1
- package/types/components/FAB/StyledFAB.d.ts +4 -6
package/.turbo/turbo-build.log
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
[1msrc/index.ts[22m → [1mlib/index.js, es/index.js[22m...[39m
|
|
3
3
|
[1m[33m(!) Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.[39m[22m
|
|
4
4
|
[1m[33m(!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/home/runner/work/hero-design/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning[39m[22m
|
|
5
|
-
[32mcreated [1mlib/index.js, es/index.js[22m in [1m57.
|
|
5
|
+
[32mcreated [1mlib/index.js, es/index.js[22m in [1m57.4s[22m[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @hero-design/rn
|
|
2
2
|
|
|
3
|
+
## 8.60.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2747](https://github.com/Thinkei/hero-design/pull/2747) [`28106e711`](https://github.com/Thinkei/hero-design/commit/28106e711ef6a127e4bfa0890535489649ff516c) Thanks [@vinhphan-eh](https://github.com/vinhphan-eh)! - [FAB][fab.actiongroup][Scrollables with FAB] Update animations using Animated
|
|
8
|
+
|
|
3
9
|
## 8.59.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/es/index.js
CHANGED
|
@@ -14386,7 +14386,8 @@ var Error$1 = function Error(_ref2) {
|
|
|
14386
14386
|
}, nativeProps));
|
|
14387
14387
|
};
|
|
14388
14388
|
|
|
14389
|
-
var
|
|
14389
|
+
var AnimatedTouchableHighlight = Animated.createAnimatedComponent(TouchableHighlight);
|
|
14390
|
+
var StyledFAB$1 = index$9(AnimatedTouchableHighlight)(function (_ref) {
|
|
14390
14391
|
var theme = _ref.theme,
|
|
14391
14392
|
themeActive = _ref.themeActive;
|
|
14392
14393
|
return {
|
|
@@ -14401,7 +14402,8 @@ var StyledFAB$1 = index$9(TouchableHighlight)(function (_ref) {
|
|
|
14401
14402
|
shadowColor: theme.__hd__.fab.shadows.color,
|
|
14402
14403
|
shadowOffset: theme.__hd__.fab.shadows.offset,
|
|
14403
14404
|
shadowRadius: theme.__hd__.fab.shadows.radius,
|
|
14404
|
-
shadowOpacity: theme.__hd__.fab.shadows.opacity
|
|
14405
|
+
shadowOpacity: theme.__hd__.fab.shadows.opacity,
|
|
14406
|
+
height: theme.__hd__.fab.sizes.height
|
|
14405
14407
|
};
|
|
14406
14408
|
});
|
|
14407
14409
|
var StyledFABIcon = index$9(Icon)(function (_ref2) {
|
|
@@ -14493,16 +14495,14 @@ var IconWithTextContent = function IconWithTextContent(_ref2) {
|
|
|
14493
14495
|
testID: "styled-fab-icon"
|
|
14494
14496
|
})), /*#__PURE__*/React.createElement(StyledFABText, null, title));
|
|
14495
14497
|
};
|
|
14496
|
-
var
|
|
14497
|
-
|
|
14498
|
-
|
|
14499
|
-
|
|
14500
|
-
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
},
|
|
14505
|
-
duration: Platform.OS === 'ios' ? 300 : 400
|
|
14498
|
+
var animateWidth = function animateWidth() {
|
|
14499
|
+
LayoutAnimation.configureNext({
|
|
14500
|
+
duration: Platform.OS === 'ios' ? 200 : 400,
|
|
14501
|
+
update: {
|
|
14502
|
+
type: 'spring',
|
|
14503
|
+
springDamping: Platform.OS === 'ios' ? 1 : 1.5
|
|
14504
|
+
}
|
|
14505
|
+
});
|
|
14506
14506
|
};
|
|
14507
14507
|
var FAB$1 = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
14508
14508
|
var _StyleSheet$flatten, _StyleSheet$flatten2;
|
|
@@ -14514,61 +14514,99 @@ var FAB$1 = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
14514
14514
|
active = _ref3.active,
|
|
14515
14515
|
style = _ref3.style;
|
|
14516
14516
|
var theme = useTheme();
|
|
14517
|
-
var _React$useState = React.useState(
|
|
14518
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
14519
|
-
canAnimate = _React$useState2[0],
|
|
14520
|
-
setCanAnimate = _React$useState2[1];
|
|
14521
|
-
var _React$useState3 = React.useState({
|
|
14517
|
+
var _React$useState = React.useState({
|
|
14522
14518
|
hideTitle: false,
|
|
14523
14519
|
hideButton: false
|
|
14524
14520
|
}),
|
|
14525
|
-
_React$
|
|
14526
|
-
displayState = _React$
|
|
14527
|
-
setDisplayState = _React$
|
|
14521
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
14522
|
+
displayState = _React$useState2[0],
|
|
14523
|
+
setDisplayState = _React$useState2[1];
|
|
14528
14524
|
var isIconOnly = displayState.hideTitle || active || !title;
|
|
14525
|
+
var animatedValues = {
|
|
14526
|
+
opacity: React.useRef(new Animated.Value(1)).current,
|
|
14527
|
+
width: React.useRef(new Animated.Value(1)).current,
|
|
14528
|
+
translateY: React.useRef(new Animated.Value(0)).current
|
|
14529
|
+
};
|
|
14530
|
+
var marginBottom = Number((_StyleSheet$flatten = StyleSheet$1.flatten(style)) === null || _StyleSheet$flatten === void 0 ? void 0 : _StyleSheet$flatten.marginBottom) || 0;
|
|
14531
|
+
var _React$useState3 = React.useState(0),
|
|
14532
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
14533
|
+
buttonWidth = _React$useState4[0],
|
|
14534
|
+
setButtonWidth = _React$useState4[1];
|
|
14535
|
+
var hasSetButtonWidth = buttonWidth > 0;
|
|
14529
14536
|
React.useImperativeHandle(ref, function () {
|
|
14530
14537
|
return {
|
|
14531
14538
|
show: function show() {
|
|
14539
|
+
Animated.spring(animatedValues.translateY, {
|
|
14540
|
+
toValue: 0,
|
|
14541
|
+
useNativeDriver: true
|
|
14542
|
+
}).start();
|
|
14532
14543
|
setDisplayState({
|
|
14533
14544
|
hideButton: false,
|
|
14534
14545
|
hideTitle: false
|
|
14535
14546
|
});
|
|
14547
|
+
animateWidth();
|
|
14548
|
+
Animated.spring(animatedValues.opacity, {
|
|
14549
|
+
toValue: 1,
|
|
14550
|
+
useNativeDriver: true
|
|
14551
|
+
}).start();
|
|
14536
14552
|
},
|
|
14537
14553
|
collapse: function collapse() {
|
|
14554
|
+
Animated.parallel([Animated.spring(animatedValues.opacity, {
|
|
14555
|
+
toValue: 1,
|
|
14556
|
+
useNativeDriver: true
|
|
14557
|
+
}), Animated.spring(animatedValues.translateY, {
|
|
14558
|
+
toValue: 0,
|
|
14559
|
+
useNativeDriver: true
|
|
14560
|
+
})]).start();
|
|
14561
|
+
animateWidth();
|
|
14538
14562
|
setDisplayState({
|
|
14539
14563
|
hideButton: false,
|
|
14540
14564
|
hideTitle: true
|
|
14541
14565
|
});
|
|
14542
14566
|
},
|
|
14543
14567
|
hide: function hide() {
|
|
14544
|
-
|
|
14545
|
-
|
|
14546
|
-
|
|
14568
|
+
Animated.stagger(20, [Animated.spring(animatedValues.opacity, {
|
|
14569
|
+
toValue: 0,
|
|
14570
|
+
useNativeDriver: true
|
|
14571
|
+
}), Animated.spring(animatedValues.translateY, {
|
|
14572
|
+
toValue: 1,
|
|
14573
|
+
useNativeDriver: true
|
|
14574
|
+
})]).start(function () {
|
|
14575
|
+
animateWidth();
|
|
14576
|
+
setDisplayState(function (previousState) {
|
|
14577
|
+
return _objectSpread2(_objectSpread2({}, previousState), {}, {
|
|
14578
|
+
hideButton: true
|
|
14579
|
+
});
|
|
14547
14580
|
});
|
|
14548
14581
|
});
|
|
14549
14582
|
}
|
|
14550
14583
|
};
|
|
14551
14584
|
}, []);
|
|
14552
|
-
React.
|
|
14553
|
-
|
|
14554
|
-
|
|
14555
|
-
}
|
|
14556
|
-
}, [isIconOnly, displayState.hideButton, canAnimate]);
|
|
14557
|
-
var marginBottom = Number((_StyleSheet$flatten = StyleSheet$1.flatten(style)) === null || _StyleSheet$flatten === void 0 ? void 0 : _StyleSheet$flatten.marginBottom) || 0;
|
|
14558
|
-
return /*#__PURE__*/React.createElement(StyledFAB$1
|
|
14559
|
-
/** Add a small timeout before executing animation to prevent flakiness */, {
|
|
14560
|
-
onLayout: function onLayout() {
|
|
14561
|
-
return setTimeout(function () {
|
|
14562
|
-
return setCanAnimate(true);
|
|
14563
|
-
}, 500);
|
|
14585
|
+
return /*#__PURE__*/React.createElement(StyledFAB$1, {
|
|
14586
|
+
onLayout: function onLayout(event) {
|
|
14587
|
+
return !hasSetButtonWidth && !active && setButtonWidth(event.nativeEvent.layout.width);
|
|
14564
14588
|
},
|
|
14565
14589
|
underlayColor: theme.__hd__.fab.colors.buttonPressedBackground,
|
|
14566
14590
|
onPress: onPress,
|
|
14567
14591
|
style: [style, {
|
|
14568
|
-
bottom: displayState.hideButton ? -(marginBottom + theme.__hd__.fab.sizes.height * 2) : (_StyleSheet$flatten2 = StyleSheet$1.flatten(style)) === null || _StyleSheet$flatten2 === void 0 ? void 0 : _StyleSheet$flatten2.bottom
|
|
14592
|
+
bottom: displayState.hideButton ? -(marginBottom + theme.__hd__.fab.sizes.height * 2) : (_StyleSheet$flatten2 = StyleSheet$1.flatten(style)) === null || _StyleSheet$flatten2 === void 0 ? void 0 : _StyleSheet$flatten2.bottom,
|
|
14593
|
+
transform: [{
|
|
14594
|
+
translateY: animatedValues.translateY.interpolate({
|
|
14595
|
+
inputRange: [0, 1],
|
|
14596
|
+
outputRange: [0, marginBottom + theme.__hd__.fab.sizes.height * 2]
|
|
14597
|
+
})
|
|
14598
|
+
}]
|
|
14569
14599
|
}],
|
|
14570
14600
|
testID: testID,
|
|
14571
14601
|
themeActive: active
|
|
14602
|
+
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
14603
|
+
style: {
|
|
14604
|
+
flexDirection: 'row',
|
|
14605
|
+
opacity: animatedValues.opacity.interpolate({
|
|
14606
|
+
inputRange: [0, 1],
|
|
14607
|
+
outputRange: [0, 1]
|
|
14608
|
+
})
|
|
14609
|
+
}
|
|
14572
14610
|
}, isIconOnly ? /*#__PURE__*/React.createElement(IconOnlyContent, {
|
|
14573
14611
|
animated: animated,
|
|
14574
14612
|
active: active,
|
|
@@ -14576,7 +14614,7 @@ var FAB$1 = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
14576
14614
|
}) : /*#__PURE__*/React.createElement(IconWithTextContent, {
|
|
14577
14615
|
icon: icon,
|
|
14578
14616
|
title: title
|
|
14579
|
-
}));
|
|
14617
|
+
})));
|
|
14580
14618
|
});
|
|
14581
14619
|
FAB$1.displayName = 'FAB';
|
|
14582
14620
|
|
|
@@ -14626,7 +14664,9 @@ var ActionItem = function ActionItem(_ref) {
|
|
|
14626
14664
|
Animated.spring(animatedValue.current, {
|
|
14627
14665
|
toValue: active ? 1 : 0,
|
|
14628
14666
|
useNativeDriver: Platform.OS !== 'web',
|
|
14629
|
-
delay: index *
|
|
14667
|
+
delay: index * 30,
|
|
14668
|
+
speed: 10,
|
|
14669
|
+
bounciness: 10
|
|
14630
14670
|
}).start();
|
|
14631
14671
|
}, [active, index]);
|
|
14632
14672
|
return /*#__PURE__*/React.createElement(Animated.View, {
|
|
@@ -14703,8 +14743,9 @@ var ActionGroup = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
14703
14743
|
_ref$fabIcon = _ref.fabIcon,
|
|
14704
14744
|
fabIcon = _ref$fabIcon === void 0 ? 'add' : _ref$fabIcon;
|
|
14705
14745
|
useDeprecation("FAB.ActionGroup's headerTitle prop will be removed in the next major release. Please remove it.", headerTitle !== undefined);
|
|
14746
|
+
var theme = useTheme();
|
|
14706
14747
|
var fabRef = useRef(null);
|
|
14707
|
-
var
|
|
14748
|
+
var animatedValue = useRef(new Animated.Value(active ? 1 : 0));
|
|
14708
14749
|
React.useImperativeHandle(ref, function () {
|
|
14709
14750
|
return {
|
|
14710
14751
|
showFAB: function showFAB() {
|
|
@@ -14722,28 +14763,28 @@ var ActionGroup = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
14722
14763
|
};
|
|
14723
14764
|
}, [fabRef]);
|
|
14724
14765
|
React.useEffect(function () {
|
|
14725
|
-
Animated.spring(
|
|
14766
|
+
Animated.spring(animatedValue.current, {
|
|
14726
14767
|
toValue: active ? 1 : 0,
|
|
14768
|
+
delay: 100,
|
|
14727
14769
|
useNativeDriver: Platform.OS !== 'web'
|
|
14728
14770
|
}).start();
|
|
14771
|
+
if (active) {
|
|
14772
|
+
var _fabRef$current4;
|
|
14773
|
+
(_fabRef$current4 = fabRef.current) === null || _fabRef$current4 === void 0 || _fabRef$current4.collapse();
|
|
14774
|
+
} else {
|
|
14775
|
+
var _fabRef$current5;
|
|
14776
|
+
(_fabRef$current5 = fabRef.current) === null || _fabRef$current5 === void 0 || _fabRef$current5.show();
|
|
14777
|
+
}
|
|
14729
14778
|
}, [active]);
|
|
14730
|
-
var
|
|
14779
|
+
var actionGroupOpacity = animatedValue.current.interpolate({
|
|
14731
14780
|
inputRange: [0, 1],
|
|
14732
14781
|
outputRange: [0, 1]
|
|
14733
14782
|
});
|
|
14734
|
-
var interpolatedFABOpacityAnimation = tranlateXAnimation.current.interpolate({
|
|
14735
|
-
inputRange: [0, 1],
|
|
14736
|
-
outputRange: [1, 0]
|
|
14737
|
-
});
|
|
14738
14783
|
return /*#__PURE__*/React.createElement(StyledContainer$2, {
|
|
14739
14784
|
testID: testID,
|
|
14740
14785
|
pointerEvents: "box-none",
|
|
14741
14786
|
style: style
|
|
14742
|
-
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
14743
|
-
style: {
|
|
14744
|
-
opacity: interpolatedFABOpacityAnimation
|
|
14745
|
-
}
|
|
14746
|
-
}, /*#__PURE__*/React.createElement(StyledFAB, {
|
|
14787
|
+
}, /*#__PURE__*/React.createElement(Animated.View, null, /*#__PURE__*/React.createElement(StyledFAB, {
|
|
14747
14788
|
key: "fab",
|
|
14748
14789
|
testID: "fab",
|
|
14749
14790
|
icon: fabIcon,
|
|
@@ -14767,7 +14808,7 @@ var ActionGroup = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
14767
14808
|
testID: "action-group",
|
|
14768
14809
|
pointerEvents: "box-none",
|
|
14769
14810
|
style: {
|
|
14770
|
-
opacity:
|
|
14811
|
+
opacity: actionGroupOpacity
|
|
14771
14812
|
}
|
|
14772
14813
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
14773
14814
|
style: [style, {
|
|
@@ -14780,7 +14821,13 @@ var ActionGroup = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
14780
14821
|
index: active ? index : items.length - index,
|
|
14781
14822
|
active: active
|
|
14782
14823
|
}));
|
|
14783
|
-
}))), /*#__PURE__*/React.createElement(StyledFAB
|
|
14824
|
+
}))), active && /*#__PURE__*/React.createElement(StyledFAB
|
|
14825
|
+
// This FAB is moved up a bit compared to the original FAB,
|
|
14826
|
+
// set marginBottom to negative value to compensate for it
|
|
14827
|
+
, {
|
|
14828
|
+
style: {
|
|
14829
|
+
marginBottom: -theme.space.xxsmall
|
|
14830
|
+
},
|
|
14784
14831
|
key: "fab-in-portal",
|
|
14785
14832
|
testID: "fab-in-portal",
|
|
14786
14833
|
icon: fabIcon,
|
|
@@ -35554,8 +35601,9 @@ var index = Object.assign(RichTextEditorWithRef, {
|
|
|
35554
35601
|
Toolbar: EditorToolbar
|
|
35555
35602
|
});
|
|
35556
35603
|
|
|
35557
|
-
var
|
|
35558
|
-
var
|
|
35604
|
+
var LAST_BREAKPOINT = 100;
|
|
35605
|
+
var MIDDLE_BREAKPOINT = 250;
|
|
35606
|
+
var MAX_ANIMATABLE_SCROLL_DISTANCE = 400;
|
|
35559
35607
|
var REF_ACTIONS_BY_COMPONENT = {
|
|
35560
35608
|
FAB: {
|
|
35561
35609
|
show: 'show',
|
|
@@ -35570,27 +35618,23 @@ var REF_ACTIONS_BY_COMPONENT = {
|
|
|
35570
35618
|
};
|
|
35571
35619
|
var AnimatedFAB = function AnimatedFAB(_ref) {
|
|
35572
35620
|
var fabProps = _ref.fabProps,
|
|
35573
|
-
contentOffsetY = _ref.contentOffsetY
|
|
35621
|
+
contentOffsetY = _ref.contentOffsetY,
|
|
35622
|
+
contentHeight = _ref.contentHeight,
|
|
35623
|
+
layoutHeight = _ref.layoutHeight;
|
|
35574
35624
|
var component = 'items' in fabProps ? 'ActionGroup' : 'FAB';
|
|
35575
|
-
var _React$useState = React.useState('down'),
|
|
35576
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
35577
|
-
currentScrollDirection = _React$useState2[0],
|
|
35578
|
-
setCurrentScrollDirection = _React$useState2[1];
|
|
35579
|
-
var _React$useState3 = React.useState(0),
|
|
35580
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
35581
|
-
lastScrollY = _React$useState4[0],
|
|
35582
|
-
setLastScrollY = _React$useState4[1];
|
|
35583
|
-
var _React$useState5 = React.useState('show'),
|
|
35584
|
-
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
35585
|
-
fabState = _React$useState6[0],
|
|
35586
|
-
setFabState = _React$useState6[1];
|
|
35587
|
-
var _React$useState7 = React.useState(SHOW_AND_HIDE_BREAKPOINT),
|
|
35588
|
-
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
35589
|
-
remainingScrollOffset = _React$useState8[0],
|
|
35590
|
-
setRemainingScrollOffset = _React$useState8[1];
|
|
35591
35625
|
var ref = React.useRef(null);
|
|
35626
|
+
var currentContentHeight = React.useRef(0);
|
|
35627
|
+
var currentLayoutHeight = React.useRef(0);
|
|
35628
|
+
/** fabState is used to avoid calling duplicated animations. */
|
|
35629
|
+
var fabState = React.useRef('show');
|
|
35630
|
+
/** remainingScrollOffset determines whether to animate the FAB. */
|
|
35631
|
+
var remainingScrollOffset = React.useRef(MAX_ANIMATABLE_SCROLL_DISTANCE);
|
|
35632
|
+
/** currentScrollDirection is used to determine the scroll direction. */
|
|
35633
|
+
var currentScrollDirection = React.useRef('down');
|
|
35634
|
+
/** lastScrollY is the scrollY from the preview scroll event. */
|
|
35635
|
+
var lastScrollY = React.useRef(0);
|
|
35592
35636
|
var animateFab = React.useCallback(function (newState) {
|
|
35593
|
-
if (fabState !== newState) {
|
|
35637
|
+
if (fabState.current !== newState) {
|
|
35594
35638
|
if (newState === 'show') {
|
|
35595
35639
|
var _ref$current;
|
|
35596
35640
|
(_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current[REF_ACTIONS_BY_COMPONENT[component].show]();
|
|
@@ -35601,37 +35645,64 @@ var AnimatedFAB = function AnimatedFAB(_ref) {
|
|
|
35601
35645
|
var _ref$current3;
|
|
35602
35646
|
(_ref$current3 = ref.current) === null || _ref$current3 === void 0 || _ref$current3[REF_ACTIONS_BY_COMPONENT[component].collapse]();
|
|
35603
35647
|
}
|
|
35604
|
-
|
|
35605
|
-
}
|
|
35606
|
-
}, [fabState, component]);
|
|
35607
|
-
// Listen to ScrollView's contentOffsetY value
|
|
35608
|
-
contentOffsetY.addListener(function (_ref2) {
|
|
35609
|
-
var value = _ref2.value;
|
|
35610
|
-
if (value < 0) {
|
|
35611
|
-
return;
|
|
35612
|
-
}
|
|
35613
|
-
var newScrollDirection = value > lastScrollY ? 'down' : 'up';
|
|
35614
|
-
var isScrollingDown = newScrollDirection === 'down';
|
|
35615
|
-
if (newScrollDirection !== currentScrollDirection || lastScrollY === 0) {
|
|
35616
|
-
setLastScrollY(value);
|
|
35617
|
-
setCurrentScrollDirection(newScrollDirection);
|
|
35618
|
-
}
|
|
35619
|
-
var offsetFromLastDirection = Math.abs(value - lastScrollY);
|
|
35620
|
-
var offsetDiff = Math.round(Math.max(remainingScrollOffset - offsetFromLastDirection, 0));
|
|
35621
|
-
if (remainingScrollOffset > 0) {
|
|
35622
|
-
if (offsetDiff === SHOW_AND_HIDE_BREAKPOINT) {
|
|
35623
|
-
animateFab(isScrollingDown ? 'show' : 'hide');
|
|
35624
|
-
} else if (offsetDiff <= SHOW_AND_HIDE_BREAKPOINT && offsetDiff > COLLAPSE_BREAKPOINT) {
|
|
35625
|
-
animateFab('collapse');
|
|
35626
|
-
} else if (offsetDiff <= COLLAPSE_BREAKPOINT) {
|
|
35627
|
-
animateFab(isScrollingDown ? 'hide' : 'show');
|
|
35628
|
-
}
|
|
35629
|
-
setRemainingScrollOffset(offsetDiff);
|
|
35648
|
+
fabState.current = newState;
|
|
35630
35649
|
}
|
|
35631
|
-
});
|
|
35650
|
+
}, [component]);
|
|
35632
35651
|
React.useEffect(function () {
|
|
35633
|
-
|
|
35634
|
-
|
|
35652
|
+
contentHeight.addListener(function (_ref2) {
|
|
35653
|
+
var value = _ref2.value;
|
|
35654
|
+
if (value > 0 && value !== currentContentHeight.current) {
|
|
35655
|
+
currentContentHeight.current = value;
|
|
35656
|
+
}
|
|
35657
|
+
});
|
|
35658
|
+
layoutHeight.addListener(function (_ref3) {
|
|
35659
|
+
var value = _ref3.value;
|
|
35660
|
+
if (value > 0 && value !== currentLayoutHeight.current) {
|
|
35661
|
+
currentLayoutHeight.current = value;
|
|
35662
|
+
}
|
|
35663
|
+
});
|
|
35664
|
+
// Listen to ScrollView's contentOffsetY value
|
|
35665
|
+
contentOffsetY.addListener(function (_ref4) {
|
|
35666
|
+
var value = _ref4.value;
|
|
35667
|
+
if (value < 0 ||
|
|
35668
|
+
// Prevent calling the function if the scroll is not significant
|
|
35669
|
+
value > 0 && Math.abs(value - lastScrollY.current) < 5) {
|
|
35670
|
+
return;
|
|
35671
|
+
}
|
|
35672
|
+
// Scroll up to top, bouncing included.
|
|
35673
|
+
if (value === 0 && lastScrollY.current !== 0) {
|
|
35674
|
+
animateFab('show');
|
|
35675
|
+
}
|
|
35676
|
+
var newScrollDirection = value >= lastScrollY.current ? 'down' : 'up';
|
|
35677
|
+
if (newScrollDirection !== currentScrollDirection.current) {
|
|
35678
|
+
// If scroll direction changes, reset all values
|
|
35679
|
+
currentScrollDirection.current = newScrollDirection;
|
|
35680
|
+
remainingScrollOffset.current = MAX_ANIMATABLE_SCROLL_DISTANCE;
|
|
35681
|
+
}
|
|
35682
|
+
var hasReachedBottom = value + currentLayoutHeight.current >= currentContentHeight.current;
|
|
35683
|
+
// Scroll down to bottom, bouncing included.
|
|
35684
|
+
if (hasReachedBottom) {
|
|
35685
|
+
animateFab('hide');
|
|
35686
|
+
return;
|
|
35687
|
+
}
|
|
35688
|
+
if (remainingScrollOffset.current) {
|
|
35689
|
+
var offsetDiff = Math.round(Math.max(Math.abs(value - lastScrollY.current), 0));
|
|
35690
|
+
var newRemainingScrollOffset = Math.max(remainingScrollOffset.current - offsetDiff, 0);
|
|
35691
|
+
if (newRemainingScrollOffset <= LAST_BREAKPOINT) {
|
|
35692
|
+
animateFab(currentScrollDirection.current === 'down' ? 'hide' : 'show');
|
|
35693
|
+
} else if (newRemainingScrollOffset <= MIDDLE_BREAKPOINT) {
|
|
35694
|
+
animateFab('collapse');
|
|
35695
|
+
}
|
|
35696
|
+
remainingScrollOffset.current = newRemainingScrollOffset;
|
|
35697
|
+
}
|
|
35698
|
+
lastScrollY.current = value;
|
|
35699
|
+
});
|
|
35700
|
+
return function () {
|
|
35701
|
+
contentOffsetY.removeAllListeners();
|
|
35702
|
+
contentHeight.removeAllListeners();
|
|
35703
|
+
layoutHeight.removeAllListeners();
|
|
35704
|
+
};
|
|
35705
|
+
}, [contentHeight, contentOffsetY, layoutHeight]);
|
|
35635
35706
|
return component === 'FAB' ? /*#__PURE__*/React.createElement(FAB, _extends$1({
|
|
35636
35707
|
ref: ref
|
|
35637
35708
|
}, fabProps)) : /*#__PURE__*/React.createElement(ActionGroup, _extends$1({
|
|
@@ -35643,6 +35714,8 @@ function AnimatedScroller(_ref) {
|
|
|
35643
35714
|
var ScrollComponent = _ref.ScrollComponent,
|
|
35644
35715
|
fabProps = _ref.fabProps;
|
|
35645
35716
|
var contentOffsetY = React.useRef(new Animated.Value(0)).current;
|
|
35717
|
+
var contentHeight = React.useRef(new Animated.Value(0)).current;
|
|
35718
|
+
var layoutHeight = React.useRef(new Animated.Value(0)).current;
|
|
35646
35719
|
// Common props for all ScrollView, FlatList and SectionList.
|
|
35647
35720
|
var _ScrollComponent$prop = ScrollComponent.props,
|
|
35648
35721
|
onScroll = _ScrollComponent$prop.onScroll,
|
|
@@ -35653,6 +35726,12 @@ function AnimatedScroller(_ref) {
|
|
|
35653
35726
|
nativeEvent: {
|
|
35654
35727
|
contentOffset: {
|
|
35655
35728
|
y: contentOffsetY
|
|
35729
|
+
},
|
|
35730
|
+
contentSize: {
|
|
35731
|
+
height: contentHeight
|
|
35732
|
+
},
|
|
35733
|
+
layoutMeasurement: {
|
|
35734
|
+
height: layoutHeight
|
|
35656
35735
|
}
|
|
35657
35736
|
}
|
|
35658
35737
|
}], {
|
|
@@ -35661,7 +35740,9 @@ function AnimatedScroller(_ref) {
|
|
|
35661
35740
|
})
|
|
35662
35741
|
})), !!fabProps && /*#__PURE__*/React.createElement(AnimatedFAB, {
|
|
35663
35742
|
fabProps: fabProps,
|
|
35664
|
-
contentOffsetY: contentOffsetY
|
|
35743
|
+
contentOffsetY: contentOffsetY,
|
|
35744
|
+
contentHeight: contentHeight,
|
|
35745
|
+
layoutHeight: layoutHeight
|
|
35665
35746
|
}));
|
|
35666
35747
|
}
|
|
35667
35748
|
|