@geastack/elements 0.1.5 → 0.1.7

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": "@geastack/elements",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Non-core GeaStack JSX elements and native element backends.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -41,6 +41,6 @@
41
41
  },
42
42
  "sideEffects": false,
43
43
  "dependencies": {
44
- "@geastack/core": "^0.1.36"
44
+ "@geastack/core": "^0.1.40"
45
45
  }
46
46
  }
@@ -1,5 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  #include "internal.h"
3
+ #include "input_retirement.h"
3
4
 
4
5
  #include "tree_state.h"
5
6
 
@@ -291,6 +292,7 @@ void Tree::setScrollLeft(int node, int scrollLeft)
291
292
  if (node < 0 || node >= nodeCount()) return;
292
293
  Node &n = treeState().nodes[node];
293
294
  if (!isViewLikeNodeType(n.type) || !scrollsOverflowX(n.computedStyle()) || n.type == NodeType::VirtualList) return;
295
+ if (animateSnapPageScroll(node, true, scrollLeft)) return;
294
296
  const int maxX = ViewRenderer::scrollMaxX(n);
295
297
  if (scrollLeft < 0) scrollLeft = 0;
296
298
  if (scrollLeft > maxX) scrollLeft = maxX;
@@ -317,6 +319,7 @@ void Tree::setScrollTop(int node, int scrollTop)
317
319
  return;
318
320
  }
319
321
  if (!isViewLikeNodeType(n.type) || !scrollsOverflowY(n.computedStyle())) return;
322
+ if (animateSnapPageScroll(node, false, scrollTop)) return;
320
323
  const int maxY = ViewRenderer::scrollMaxY(n);
321
324
  if (scrollTop < 0) scrollTop = 0;
322
325
  if (scrollTop > maxY) scrollTop = maxY;
@@ -343,39 +346,56 @@ void Tree::scrollIntoView(int node)
343
346
  #endif
344
347
  }
345
348
 
349
+ void Tree::scrollIntoViewKeepingPadding(int node)
350
+ {
351
+ #if GEA_CSS_SCROLLING
352
+ scrollIntoView(node);
353
+ if (treeState().pendingScrollIntoViewNode == node) treeState().pendingScrollIntoViewKeepsPadding = true;
354
+ #else
355
+ (void)node;
356
+ #endif
357
+ }
358
+
346
359
  void Tree::applyPendingScrollIntoView()
347
360
  {
348
361
  #if GEA_CSS_SCROLLING
349
362
  auto &state = treeState();
350
363
  const int node = state.pendingScrollIntoViewNode;
351
364
  if (node < 0) return;
352
- if (node >= state.nodeCount || !state.nodeActive[node]) {
365
+ const bool keepPadding = state.pendingScrollIntoViewKeepsPadding;
366
+ auto finish = [&state] {
353
367
  state.pendingScrollIntoViewNode = -1;
368
+ state.pendingScrollIntoViewKeepsPadding = false;
369
+ };
370
+ if (node >= state.nodeCount || !state.nodeActive[node]) {
371
+ finish();
354
372
  return;
355
373
  }
356
374
  const int scroller = nearestScrollableAncestorY(state, node);
357
375
  if (scroller < 0) return;
358
376
 
359
377
  const Node &container = state.nodes[scroller];
378
+ const int padTop = keepPadding ? container.computedStyle().padding[0] : 0;
379
+ const int padBottom = keepPadding ? container.computedStyle().padding[2] : 0;
360
380
  const int viewportTop = container.layout.scroll_y;
361
381
  const int viewportBottom = viewportTop + container.layout.height;
362
382
  int targetTop = 0;
363
383
  int targetBottom = 0;
364
384
  if (!targetContentBoundsY(state, scroller, node, &targetTop, &targetBottom)) {
365
- state.pendingScrollIntoViewNode = -1;
385
+ finish();
366
386
  return;
367
387
  }
368
388
 
369
389
  int next = container.layout.scroll_y;
370
- if (targetTop < viewportTop) {
371
- next = targetTop;
372
- } else if (targetBottom > viewportBottom) {
373
- next = targetBottom - container.layout.height;
390
+ if (targetTop - padTop < viewportTop) {
391
+ next = targetTop - padTop;
392
+ } else if (targetBottom + padBottom > viewportBottom) {
393
+ next = targetBottom + padBottom - container.layout.height;
374
394
  } else {
375
- state.pendingScrollIntoViewNode = -1;
395
+ finish();
376
396
  return;
377
397
  }
378
- state.pendingScrollIntoViewNode = -1;
398
+ finish();
379
399
  setScrollTop(scroller, next);
380
400
  #else
381
401