react-ui-basics 0.0.210 → 0.0.211

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-ui-basics",
3
- "version": "0.0.210",
3
+ "version": "0.0.211",
4
4
  "description": "",
5
5
  "module": "index.js",
6
6
  "_main": "index.cjs.js",
package/src/Scrollable.js CHANGED
@@ -244,17 +244,18 @@ class Scrollable extends PureComponent {
244
244
  const updateVerticalScrollbar = () => {
245
245
  const scrollHeight = scrollHeightOf(viewport);
246
246
  const scrollbarHeight = offsetHeightOf(scrollbar);
247
+ const containerHeight = offsetHeightOf(container);
247
248
 
248
249
  !adjustedScrollWidth && adjustScrollWidth();
249
250
 
250
251
  const newRatio = scrollHeight / scrollbarHeight;
251
- if ((ratio === newRatio && Number.isFinite(newRatio)) || Number.isNaN(newRatio)) return;
252
+ if (!containerHeight || (ratio === newRatio && Number.isFinite(newRatio)) || Number.isNaN(newRatio)) return;
252
253
 
253
254
  const offsetHeight = offsetHeightOf(viewport);
254
255
  const horizontalScrollBarOffset = statusH() !== WITHOUT_SCROLL ? __clientHeight(scrollbarH) + Math.max(NATIVE_SCROLL_HEIGHT, 0) : 0;
255
256
 
256
- let containerOffsetHeight = offsetHeightOf(container) + horizontalScrollBarOffset;
257
- if (containerOffsetHeight === scrollHeight && status() === WITHOUT_SCROLL)
257
+ let containerOffsetHeight = containerHeight + horizontalScrollBarOffset;
258
+ if (containerOffsetHeight > scrollHeight && status() === WITHOUT_SCROLL)
258
259
  return;
259
260
 
260
261
  if (props().autoScrollTop && scrollHeight - offsetHeight - __scrollTop(viewport) <= 20 && newRatio < ratio && Number.isFinite(newRatio) && Number.isFinite(ratio)) {
@@ -262,10 +263,11 @@ class Scrollable extends PureComponent {
262
263
  }
263
264
 
264
265
  ratio = newRatio;
265
- styleOf(thumb).height = (scrollbarHeight / newRatio) + 'px';
266
+ if (newRatio > 1.02)
267
+ styleOf(thumb).height = (scrollbarHeight / newRatio) + 'px';
266
268
 
267
269
  styleOf(container).height = scrollHeight - horizontalScrollBarOffset + 'px';
268
- containerOffsetHeight = offsetHeightOf(container) + horizontalScrollBarOffset;
270
+ containerOffsetHeight = containerHeight + horizontalScrollBarOffset;
269
271
 
270
272
  if (scrollBarModeOf(props()) === SCROLLBAR_MODE_HIDDEN) {
271
273
  if (status() !== WITHOUT_SCROLL)
@@ -274,7 +276,7 @@ class Scrollable extends PureComponent {
274
276
  return
275
277
  }
276
278
 
277
- if (containerOffsetHeight < scrollHeight) {
279
+ if (containerOffsetHeight <= scrollHeight) {
278
280
  adjustedScrollWidth = false;
279
281
  showScrollbar(scrollbar, viewport, adjustScrollWidth);
280
282
  } else {
@@ -289,25 +291,25 @@ class Scrollable extends PureComponent {
289
291
  };
290
292
 
291
293
  const updateHorizontalScrollbar = () => {
292
-
293
294
  const scrollWidth = scrollWidthOf(viewport);
294
295
  const scrollbarWidth = offsetWidthOf(scrollbarH);
296
+ const containerWidth = offsetWidthOf(container);
295
297
 
296
298
  !adjustedScrollWidth && adjustScrollWidth();
297
299
 
298
300
  const newRatio = scrollWidth / scrollbarWidth;
299
- if ((ratioH === newRatio && Number.isFinite(newRatio)) || Number.isNaN(newRatio)) return;
301
+ if (!containerWidth || (ratioH === newRatio && Number.isFinite(newRatio)) || Number.isNaN(newRatio)) return;
300
302
 
301
303
  const offsetWidth = offsetWidthOf(viewport);
302
-
303
304
  const verticalScrollBarOffset = status() !== WITHOUT_SCROLL ? __clientWidth(scrollbar) + Math.max(NATIVE_SCROLL_WIDTH, 0) : 0;
304
- let containerOffsetWidth = offsetWidthOf(container) + verticalScrollBarOffset;
305
305
 
306
- if (containerOffsetWidth === scrollWidth && statusH() === WITHOUT_SCROLL)
306
+ let containerOffsetWidth = containerWidth + verticalScrollBarOffset;
307
+ if (containerOffsetWidth > scrollWidth && statusH() === WITHOUT_SCROLL)
307
308
  return;
308
309
 
309
310
  ratioH = newRatio;
310
- styleOf(thumbH).width = (scrollbarWidth / newRatio) + 'px';
311
+ if (newRatio > 1.02)
312
+ styleOf(thumbH).width = (scrollbarWidth / newRatio) + 'px';
311
313
 
312
314
 
313
315
  if (horizontalScrollBarModeOf(props()) === SCROLLBAR_MODE_HIDDEN) {
@@ -318,9 +320,9 @@ class Scrollable extends PureComponent {
318
320
  }
319
321
 
320
322
  styleOf(container).width = (scrollWidth - verticalScrollBarOffset) + 'px';
321
- containerOffsetWidth = offsetWidthOf(container) + verticalScrollBarOffset;
323
+ containerOffsetWidth = containerWidth + verticalScrollBarOffset;
322
324
 
323
- if (containerOffsetWidth < scrollWidth) {
325
+ if (containerOffsetWidth <= scrollWidth) {
324
326
  adjustedScrollWidth = false;
325
327
  showHorizontalScrollbar(scrollbarH, viewport, adjustScrollWidth);
326
328
  } else {
@@ -341,12 +343,14 @@ class Scrollable extends PureComponent {
341
343
  };
342
344
  } else if (sbm !== SCROLLBAR_RESIZE_DISABLED)
343
345
  update = updateVerticalScrollbar
344
- else
345
- update = updateVerticalScrollbar
346
+ else if (hsbm !== SCROLLBAR_RESIZE_DISABLED)
347
+ update = updateHorizontalScrollbar
346
348
 
347
- initTimeout = setTimeout(() => {
348
- resizeInterval = setInterval(update, 50);
349
- }, 200)
349
+ if (update) {
350
+ initTimeout = setTimeout(() => {
351
+ resizeInterval = setInterval(update, 50);
352
+ }, 200)
353
+ }
350
354
  };
351
355
 
352
356
  that[ReactConstants[0]] = init;
package/src/Tools.ts CHANGED
@@ -17,7 +17,7 @@ export const NOOP = () => {
17
17
 
18
18
  export const orNoop = <T>(f: (...a: any) => T) => f || NOOP;
19
19
 
20
- export const getRandomId = (prefix:string) => prefix + Math.random();
20
+ export const getRandomId = (prefix: string) => prefix + Math.random();
21
21
 
22
22
  export const ref = (name, component) => {
23
23
  const refKey = "__" + name;