@micromag/element-scroll 0.3.369 → 0.3.370

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/es/index.js CHANGED
@@ -15,6 +15,7 @@ var propTypes = {
15
15
  verticalAlign: PropTypes.oneOf(['top', 'middle', 'bottom']),
16
16
  className: PropTypes.string,
17
17
  children: PropTypes.node,
18
+ scrollPosition: PropTypes.oneOf([PropTypes.number, PropTypes.string]),
18
19
  onScrolledBottom: PropTypes.func,
19
20
  onScrolledNotBottom: PropTypes.func,
20
21
  onScrollHeightChange: PropTypes.func,
@@ -31,6 +32,7 @@ var defaultProps = {
31
32
  verticalAlign: null,
32
33
  className: null,
33
34
  children: null,
35
+ scrollPosition: null,
34
36
  onScrolledBottom: null,
35
37
  onScrolledNotBottom: null,
36
38
  onScrollHeightChange: null,
@@ -47,6 +49,7 @@ function Scroll(_ref) {
47
49
  verticalAlign = _ref.verticalAlign,
48
50
  className = _ref.className,
49
51
  children = _ref.children,
52
+ scrollPosition = _ref.scrollPosition,
50
53
  onScrolledBottom = _ref.onScrolledBottom,
51
54
  onScrolledNotBottom = _ref.onScrolledNotBottom,
52
55
  onScrollHeightChange = _ref.onScrollHeightChange,
@@ -136,6 +139,11 @@ function Scroll(_ref) {
136
139
  });
137
140
  }
138
141
  }, [scrollableHeight, scrolleeHeight, onScrollHeightChange]);
142
+ useEffect(function () {
143
+ if (scrollableRef.current !== null && scrollPosition !== null) {
144
+ scrollableRef.current.scrollTop = scrollPosition;
145
+ }
146
+ }, [scrolleeRef, scrollPosition]);
139
147
  return /*#__PURE__*/React.createElement("div", {
140
148
  className: classNames([styles.container, (_ref3 = {}, _defineProperty(_ref3, styles.withScroll, !disabled), _defineProperty(_ref3, styles.containOverscroll, contain), _defineProperty(_ref3, className, className !== null), _defineProperty(_ref3, styles[verticalAlign], verticalAlign !== null), _defineProperty(_ref3, styles.withArrow, showArrow && withArrow), _defineProperty(_ref3, styles.withShadow, withShadow), _ref3)]),
141
149
  style: finalStyle
@@ -158,8 +166,8 @@ function Scroll(_ref) {
158
166
  points: ".38 11.38 5 16 9.62 11.38 8.56 10.32 5.75 13.13 5.75 1.61 4.25 1.61 4.25 13.13 1.44 10.32 .38 11.38"
159
167
  }))) : null);
160
168
  }
161
- Scroll.propTypes = propTypes;
162
169
  Scroll.defaultProps = defaultProps;
170
+ Scroll.propTypes = propTypes;
163
171
  var Scroll$1 = /*#__PURE__*/React.forwardRef(function (props, ref) {
164
172
  return /*#__PURE__*/React.createElement(Scroll, Object.assign({
165
173
  scrollContainerRef: ref
package/lib/index.js CHANGED
@@ -25,6 +25,7 @@ var propTypes = {
25
25
  verticalAlign: PropTypes__default["default"].oneOf(['top', 'middle', 'bottom']),
26
26
  className: PropTypes__default["default"].string,
27
27
  children: PropTypes__default["default"].node,
28
+ scrollPosition: PropTypes__default["default"].oneOf([PropTypes__default["default"].number, PropTypes__default["default"].string]),
28
29
  onScrolledBottom: PropTypes__default["default"].func,
29
30
  onScrolledNotBottom: PropTypes__default["default"].func,
30
31
  onScrollHeightChange: PropTypes__default["default"].func,
@@ -41,6 +42,7 @@ var defaultProps = {
41
42
  verticalAlign: null,
42
43
  className: null,
43
44
  children: null,
45
+ scrollPosition: null,
44
46
  onScrolledBottom: null,
45
47
  onScrolledNotBottom: null,
46
48
  onScrollHeightChange: null,
@@ -57,6 +59,7 @@ function Scroll(_ref) {
57
59
  verticalAlign = _ref.verticalAlign,
58
60
  className = _ref.className,
59
61
  children = _ref.children,
62
+ scrollPosition = _ref.scrollPosition,
60
63
  onScrolledBottom = _ref.onScrolledBottom,
61
64
  onScrolledNotBottom = _ref.onScrolledNotBottom,
62
65
  onScrollHeightChange = _ref.onScrollHeightChange,
@@ -146,6 +149,11 @@ function Scroll(_ref) {
146
149
  });
147
150
  }
148
151
  }, [scrollableHeight, scrolleeHeight, onScrollHeightChange]);
152
+ React.useEffect(function () {
153
+ if (scrollableRef.current !== null && scrollPosition !== null) {
154
+ scrollableRef.current.scrollTop = scrollPosition;
155
+ }
156
+ }, [scrolleeRef, scrollPosition]);
149
157
  return /*#__PURE__*/React__default["default"].createElement("div", {
150
158
  className: classNames__default["default"]([styles.container, (_ref3 = {}, _defineProperty__default["default"](_ref3, styles.withScroll, !disabled), _defineProperty__default["default"](_ref3, styles.containOverscroll, contain), _defineProperty__default["default"](_ref3, className, className !== null), _defineProperty__default["default"](_ref3, styles[verticalAlign], verticalAlign !== null), _defineProperty__default["default"](_ref3, styles.withArrow, showArrow && withArrow), _defineProperty__default["default"](_ref3, styles.withShadow, withShadow), _ref3)]),
151
159
  style: finalStyle
@@ -168,8 +176,8 @@ function Scroll(_ref) {
168
176
  points: ".38 11.38 5 16 9.62 11.38 8.56 10.32 5.75 13.13 5.75 1.61 4.25 1.61 4.25 13.13 1.44 10.32 .38 11.38"
169
177
  }))) : null);
170
178
  }
171
- Scroll.propTypes = propTypes;
172
179
  Scroll.defaultProps = defaultProps;
180
+ Scroll.propTypes = propTypes;
173
181
  var Scroll$1 = /*#__PURE__*/React__default["default"].forwardRef(function (props, ref) {
174
182
  return /*#__PURE__*/React__default["default"].createElement(Scroll, Object.assign({
175
183
  scrollContainerRef: ref
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/element-scroll",
3
- "version": "0.3.369",
3
+ "version": "0.3.370",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -52,7 +52,7 @@
52
52
  "@fortawesome/fontawesome-svg-core": "^1.2.32",
53
53
  "@fortawesome/free-solid-svg-icons": "^5.15.1",
54
54
  "@fortawesome/react-fontawesome": "^0.1.13",
55
- "@micromag/core": "^0.3.369",
55
+ "@micromag/core": "^0.3.370",
56
56
  "@use-gesture/react": "^10.2.4",
57
57
  "classnames": "^2.2.6",
58
58
  "lodash": "^4.17.21",
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "55706624c2879ead4acff84015ad51df2b7d293b"
66
+ "gitHead": "69c07e59593e42e3d6f3f4e9deba937a7ea60734"
67
67
  }