react-crud-mobile 1.0.644 → 1.0.646

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.
@@ -692,20 +692,24 @@ function UIListRow(props) {
692
692
  data: item
693
693
  }))),
694
694
  row = _useState[0];
695
- var viewRef = React.useRef(null);
695
+ var targetRef = React.useRef(null);
696
696
  var _useState2 = React.useState(false),
697
- visible = _useState2[0],
698
- setVisible = _useState2[1];
699
- var windowHeight = reactNative.Dimensions.get('window').height;
700
- var checkIfVisible = function checkIfVisible() {
701
- var nodeHandle = reactNative.findNodeHandle(viewRef.current);
702
- if (nodeHandle && !visible) {
703
- reactNative.UIManager.measure(nodeHandle, function (x, y, width, height, pageX, pageY) {
704
- var isVisible = pageY >= 0 && pageY + height <= windowHeight;
705
- setVisible(isVisible);
706
- });
697
+ visivel = _useState2[0],
698
+ setVisivel = _useState2[1];
699
+ var onScroll = function onScroll() {
700
+ if (!visivel) {
701
+ var handle = reactNative.findNodeHandle(targetRef.current);
702
+ if (handle) {
703
+ reactNative.UIManager.measure(handle, function (x, y, width, height, pageX, pageY) {
704
+ var windowHeight = reactNative.Dimensions.get('window').height;
705
+ var topoVisivel = pageY >= 0 && pageY < windowHeight;
706
+ var fundoVisivel = pageY + height > 0 && pageY + height < windowHeight;
707
+ setVisivel(topoVisivel || fundoVisivel);
708
+ });
709
+ }
707
710
  }
708
711
  };
712
+ row.onScroll = onScroll;
709
713
  var onClick = function onClick(item) {
710
714
  row.call('click', {
711
715
  value: item,
@@ -714,6 +718,18 @@ function UIListRow(props) {
714
718
  index: index
715
719
  });
716
720
  };
721
+ var Child = function Child() {
722
+ if (!visivel) {
723
+ return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {});
724
+ }
725
+ return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
726
+ children: /*#__PURE__*/jsxRuntime.jsx(UIChildren, {
727
+ scope: row,
728
+ crud: row.crud,
729
+ children: props.children
730
+ })
731
+ });
732
+ };
717
733
  var ListItem = function ListItem() {
718
734
  var _useState3 = React.useState(0),
719
735
  updateIndex = _useState3[0],
@@ -730,28 +746,19 @@ function UIListRow(props) {
730
746
  scope.updateIndex = scope.updateIndex + 1;
731
747
  setUpdateIndex(++updateIndex);
732
748
  };
733
- var Child = function Child() {
734
- return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
735
- children: visible && /*#__PURE__*/jsxRuntime.jsx(UIChildren, {
736
- scope: row,
737
- crud: row.crud,
738
- children: props.children
739
- })
740
- });
741
- };
742
749
  if (!original.click) {
743
750
  return /*#__PURE__*/jsxRuntime.jsx(reactNative.View, {
744
751
  style: getRowStyle(),
745
- onLayout: checkIfVisible,
746
- ref: viewRef,
752
+ ref: targetRef,
753
+ onLayout: onScroll,
747
754
  children: /*#__PURE__*/jsxRuntime.jsx(Child, {})
748
755
  }, key);
749
756
  }
750
757
  return /*#__PURE__*/jsxRuntime.jsx(reactNative.TouchableHighlight, {
751
758
  style: getRowStyle(),
752
- ref: viewRef,
753
759
  underlayColor: 'transparent',
754
- onLayout: checkIfVisible,
760
+ ref: targetRef,
761
+ onLayout: onScroll,
755
762
  onPress: function onPress(e) {
756
763
  e.stopPropagation();
757
764
  onClick(item);
@@ -1263,10 +1270,20 @@ function UIView(_ref) {
1263
1270
  reactNative.StatusBar.setBarStyle('light-content');
1264
1271
  reactNative.StatusBar.setBackgroundColor == null || reactNative.StatusBar.setBackgroundColor(theme.colors.primary);
1265
1272
  }, []);
1273
+ var onScroll = function onScroll() {
1274
+ var crud = reactCrudUtils.ViewUtils.getCrud();
1275
+ reactCrudUtils.Utils.each(crud.scroll, function (s) {
1276
+ if (s.onScroll) {
1277
+ s.onScroll.call(s);
1278
+ }
1279
+ });
1280
+ };
1266
1281
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1267
1282
  children: [header, /*#__PURE__*/jsxRuntime.jsx(reactNative.View, {
1268
1283
  style: scope.getStyle('container', styles$9.container),
1269
1284
  children: /*#__PURE__*/jsxRuntime.jsx(reactNative.ScrollView, {
1285
+ onScroll: onScroll,
1286
+ scrollEventThrottle: 16,
1270
1287
  keyboardShouldPersistTaps: "handled",
1271
1288
  contentContainerStyle: scope.getStyle('contentContainer', {}),
1272
1289
  style: scope.getStyle('scroll', styles$9.scroll),