@geastack/elements 0.1.6 → 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 +1 -1
- package/ui/virtual_list.cpp +28 -8
package/package.json
CHANGED
package/ui/virtual_list.cpp
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
395
|
+
finish();
|
|
376
396
|
return;
|
|
377
397
|
}
|
|
378
|
-
|
|
398
|
+
finish();
|
|
379
399
|
setScrollTop(scroller, next);
|
|
380
400
|
#else
|
|
381
401
|
|