@blocklet/launcher-layout 1.5.59 → 1.5.62

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.
@@ -21,17 +21,29 @@ function CompactLayout(_ref) {
21
21
  let {
22
22
  children,
23
23
  bottom,
24
- fixBottomMaxWidth
24
+ fixBottomMaxWidth,
25
+ onBottomFix
25
26
  } = _ref;
26
27
  const mainCon = (0, _react.useRef)(null);
27
28
  const childsCon = (0, _react.useRef)(null);
28
29
  const compactCon = (0, _react.useRef)(null);
30
+ const isFix = (0, _react.useRef)(null);
29
31
  const [scrollMode, setScrollMode] = (0, _react.useState)(false);
30
32
  (0, _react.useEffect)(() => {
31
33
  const fixSize = () => {
32
34
  if (childsCon.current.scrollHeight > mainCon.current.clientHeight - compactCon.current.clientHeight || fixBottomMaxWidth && fixBottomMaxWidth > compactCon.current.clientWidth) {
35
+ if (isFix.current !== 'fix') {
36
+ onBottomFix('fix');
37
+ isFix.current = 'fix';
38
+ }
39
+
33
40
  setScrollMode(true);
34
41
  } else {
42
+ if (isFix.current !== 'scroll') {
43
+ onBottomFix('scroll');
44
+ isFix.current = 'scroll';
45
+ }
46
+
35
47
  setScrollMode(false);
36
48
  }
37
49
  };
@@ -44,7 +56,7 @@ function CompactLayout(_ref) {
44
56
  window.addEventListener('resize', fixSize);
45
57
  }
46
58
 
47
- resizeObs.observe(childsCon.current);
59
+ resizeObs.observe(mainCon.current);
48
60
  return () => {
49
61
  if (resizeObs) {
50
62
  resizeObs.disconnect();
@@ -73,9 +85,11 @@ const Container = _styledComponents.default.div.withConfig({
73
85
  CompactLayout.propTypes = {
74
86
  children: _propTypes.default.any,
75
87
  bottom: _propTypes.default.element.isRequired,
76
- fixBottomMaxWidth: _propTypes.default.number
88
+ fixBottomMaxWidth: _propTypes.default.number,
89
+ onBottomFix: _propTypes.default.func
77
90
  };
78
91
  CompactLayout.defaultProps = {
79
92
  children: [],
80
- fixBottomMaxWidth: 0
93
+ fixBottomMaxWidth: 0,
94
+ onBottomFix: () => {}
81
95
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/launcher-layout",
3
- "version": "1.5.59",
3
+ "version": "1.5.62",
4
4
  "description": "Common ux components of launcher",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -56,5 +56,5 @@
56
56
  "babel-plugin-inline-react-svg": "^2.0.1",
57
57
  "babel-plugin-styled-components": "^1.10.7"
58
58
  },
59
- "gitHead": "fec142f2ecfe136599d9b886ac44ac2d61b7ea40"
59
+ "gitHead": "09b90c32667ccd867d6e1f263452d487f67b83ab"
60
60
  }