josenanodev-react-components-library 0.2.7 → 0.2.9

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.
@@ -62,8 +62,14 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
62
62
  const [visibleListElementsIds, setVisibleListElementsIds] = (0, react_1.useState)([]);
63
63
  const [updateList, setUpdateList] = (0, react_1.useState)(false);
64
64
  const [origin, setOrigin] = (0, react_1.useState)({
65
- x: pastDatesVisible ? Math.ceil(pastDaysInitialQuantity) * cellsWidth : 0,
66
- y: 0,
65
+ x: (0, MulticalendarStatesAndSettings_1.getMulticalendarScrollLeftPosition)(multicalendarId)
66
+ ? Number((0, MulticalendarStatesAndSettings_1.getMulticalendarScrollLeftPosition)(multicalendarId))
67
+ : pastDatesVisible
68
+ ? Math.ceil(pastDaysInitialQuantity) * cellsWidth
69
+ : 0,
70
+ y: (0, MulticalendarStatesAndSettings_1.getMulticalendarScrollTopPosition)(multicalendarId)
71
+ ? Number((0, MulticalendarStatesAndSettings_1.getMulticalendarScrollTopPosition)(multicalendarId))
72
+ : 0,
67
73
  });
68
74
  const [xPosition, setXPosition] = (0, react_1.useState)(origin.x);
69
75
  const [yPosition, setYPosition] = (0, react_1.useState)(origin.y);
@@ -71,6 +77,7 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
71
77
  x: origin.x,
72
78
  y: origin.y,
73
79
  });
80
+ const [initialPositioningDone, setInitialPositioningDone] = (0, react_1.useState)(false);
74
81
  const [minimumVisibleDate, setMinimumVisibleDate] = (0, react_1.useState)(new Date());
75
82
  const [idTimeoutForCalls, setIdTimeoutForCalls] = (0, react_1.useState)(undefined);
76
83
  const [clientXPositionOnGrid, setClientXPositionOnGrid] = (0, react_1.useState)(undefined);
@@ -85,25 +92,12 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
85
92
  }, [pastDatesVisible, pastDaysInitialQuantity, cellsWidth]);
86
93
  (0, react_1.useEffect)(() => {
87
94
  //Cached positions
88
- let newYPosition = (0, MulticalendarStatesAndSettings_1.getMulticalendarScrollTopPosition)(multicalendarId);
89
- let newXPosition = (0, MulticalendarStatesAndSettings_1.getMulticalendarScrollLeftPosition)(multicalendarId);
90
- if (gridWrapperRef.current) {
91
- if (newYPosition !== null && newYPosition !== String(origin.y)) {
92
- gridWrapperRef.current.scrollTop = Number(newYPosition);
93
- (0, MulticalendarStatesAndSettings_1.eraseMulticalendarScrollTopPosition)(multicalendarId);
94
- }
95
- else {
96
- gridWrapperRef.current.scrollTop = origin.y;
97
- }
98
- if (newXPosition !== null && newXPosition !== String(origin.x)) {
99
- gridWrapperRef.current.scrollLeft = Number(newXPosition);
100
- (0, MulticalendarStatesAndSettings_1.eraseMulticalendarScrollLeftPosition)(multicalendarId);
101
- }
102
- else {
103
- gridWrapperRef.current.scrollLeft = origin.x;
104
- }
95
+ if (gridWrapperRef.current && initialPositioningDone === false) {
96
+ gridWrapperRef.current.scrollTop = origin.y;
97
+ gridWrapperRef.current.scrollLeft = origin.x;
98
+ setInitialPositioningDone(true);
105
99
  }
106
- }, [origin.y, origin.x]);
100
+ }, [origin.y, origin.x, initialPositioningDone]);
107
101
  (0, react_1.useEffect)(() => {
108
102
  if (onScrollLeftChanges) {
109
103
  onScrollLeftChanges(xPosition);
@@ -13,7 +13,7 @@ import useWindowSize from "../../hooks/useWindowsSize";
13
13
  //Utils
14
14
  import sqlToJsDate from "../../utils/sqlToJsDate";
15
15
  //Services
16
- import { eraseMulticalendarScrollLeftPosition, eraseMulticalendarScrollTopPosition, getMulticalendarScrollLeftPosition, getMulticalendarScrollTopPosition, setMulticalendarScrollLeftPosition, setMulticalendarScrollTopPosition, } from "../../Services/MulticalendarStatesAndSettings";
16
+ import { getMulticalendarScrollLeftPosition, getMulticalendarScrollTopPosition, setMulticalendarScrollLeftPosition, setMulticalendarScrollTopPosition, } from "../../Services/MulticalendarStatesAndSettings";
17
17
  const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChildren, listElementsIdsArray, language, pastDatesVisible = true, cellsWidth = 120, cellsHeight = 80, verticalAxisWidth = 280, horizontalAxisHeight = 148, pastDaysInitialQuantity = 365, futureDaysInitialQuantity = 365, chunkRenderX = 0, chunkRenderY = 0, dynamicDaysQuantity = false, draggingOverDateCells = false, waitTimeForCalls = 500, callsOnInitialView, callsOnScrollingStops, aditionalControlsComponents, upperLeftComponent, autoSavePosition, onScrollTopChanges, onScrollLeftChanges, }) => {
18
18
  //Constantes del componente
19
19
  const initialDateOffset = 1 + chunkRenderX;
@@ -34,8 +34,14 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
34
34
  const [visibleListElementsIds, setVisibleListElementsIds] = useState([]);
35
35
  const [updateList, setUpdateList] = useState(false);
36
36
  const [origin, setOrigin] = useState({
37
- x: pastDatesVisible ? Math.ceil(pastDaysInitialQuantity) * cellsWidth : 0,
38
- y: 0,
37
+ x: getMulticalendarScrollLeftPosition(multicalendarId)
38
+ ? Number(getMulticalendarScrollLeftPosition(multicalendarId))
39
+ : pastDatesVisible
40
+ ? Math.ceil(pastDaysInitialQuantity) * cellsWidth
41
+ : 0,
42
+ y: getMulticalendarScrollTopPosition(multicalendarId)
43
+ ? Number(getMulticalendarScrollTopPosition(multicalendarId))
44
+ : 0,
39
45
  });
40
46
  const [xPosition, setXPosition] = useState(origin.x);
41
47
  const [yPosition, setYPosition] = useState(origin.y);
@@ -43,6 +49,7 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
43
49
  x: origin.x,
44
50
  y: origin.y,
45
51
  });
52
+ const [initialPositioningDone, setInitialPositioningDone] = useState(false);
46
53
  const [minimumVisibleDate, setMinimumVisibleDate] = useState(new Date());
47
54
  const [idTimeoutForCalls, setIdTimeoutForCalls] = useState(undefined);
48
55
  const [clientXPositionOnGrid, setClientXPositionOnGrid] = useState(undefined);
@@ -57,25 +64,12 @@ const Multicalendar = ({ multicalendarId, ReactCellChildren, ReactListElementChi
57
64
  }, [pastDatesVisible, pastDaysInitialQuantity, cellsWidth]);
58
65
  useEffect(() => {
59
66
  //Cached positions
60
- let newYPosition = getMulticalendarScrollTopPosition(multicalendarId);
61
- let newXPosition = getMulticalendarScrollLeftPosition(multicalendarId);
62
- if (gridWrapperRef.current) {
63
- if (newYPosition !== null && newYPosition !== String(origin.y)) {
64
- gridWrapperRef.current.scrollTop = Number(newYPosition);
65
- eraseMulticalendarScrollTopPosition(multicalendarId);
66
- }
67
- else {
68
- gridWrapperRef.current.scrollTop = origin.y;
69
- }
70
- if (newXPosition !== null && newXPosition !== String(origin.x)) {
71
- gridWrapperRef.current.scrollLeft = Number(newXPosition);
72
- eraseMulticalendarScrollLeftPosition(multicalendarId);
73
- }
74
- else {
75
- gridWrapperRef.current.scrollLeft = origin.x;
76
- }
67
+ if (gridWrapperRef.current && initialPositioningDone === false) {
68
+ gridWrapperRef.current.scrollTop = origin.y;
69
+ gridWrapperRef.current.scrollLeft = origin.x;
70
+ setInitialPositioningDone(true);
77
71
  }
78
- }, [origin.y, origin.x]);
72
+ }, [origin.y, origin.x, initialPositioningDone]);
79
73
  useEffect(() => {
80
74
  if (onScrollLeftChanges) {
81
75
  onScrollLeftChanges(xPosition);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "josenanodev-react-components-library",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "author": {
5
5
  "name": "Jose Carlos Cardenas Martinez"
6
6
  },