Skip to content

Commit 76919ed

Browse files
committed
fix: 🐛 Accommodate over scroll
1 parent d00e492 commit 76919ed

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- Fixed [#576](https://github.com/SimformSolutionsPvtLtd/showcaseview/issues/576) - Fixed the showcase key update issue by removing the old controller entry and registering the new key.
44
- Fixed [#578](https://github.com/SimformSolutionsPvtLtd/showcaseview/issues/578) - Fixed showcase key issue.
5+
- Fixed [#583](https://github.com/SimformSolutionsPvtLtd/showcaseview/pull/583) - Accommodate
6+
over scroll when auto scroll is enabled.
57

68
## [5.0.0]
79

lib/src/showcase/showcase.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ class _ShowcaseState extends State<Showcase> {
563563
super.didUpdateWidget(oldWidget);
564564
if (oldWidget == widget) return;
565565
_updateControllerValues();
566-
if(oldWidget.showcaseKey != widget.showcaseKey) {
566+
if (oldWidget.showcaseKey != widget.showcaseKey) {
567567
ShowcaseService.instance.removeController(
568568
key: oldWidget.showcaseKey,
569569
id: _uniqueId,

lib/src/showcase/showcase_controller.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ class ShowcaseController {
181181
duration: showcaseView.scrollDuration,
182182
alignment: config.scrollAlignment,
183183
);
184+
// For the cases when scrollAlignment causes overscroll.
185+
await _waitForScrollToSettle();
184186

185187
isScrollRunning = false;
186188
setupShowcase(shouldUpdateOverlay: shouldUpdateOverlay);
@@ -456,6 +458,28 @@ class ShowcaseController {
456458
scheduler.addPostFrameCallback((_) => process());
457459
}
458460

461+
/// Waits until the scroll position stops changing (settles).
462+
Future<void> _waitForScrollToSettle({
463+
Duration checkInterval = const Duration(milliseconds: 60),
464+
int maxChecks = 120,
465+
}) async {
466+
final scrollableState = Scrollable.maybeOf(_context);
467+
if (scrollableState == null) return;
468+
469+
final position = scrollableState.position;
470+
var lastPixels = position.pixels;
471+
var checks = 0;
472+
473+
while (checks < maxChecks) {
474+
await Future<void>.delayed(checkInterval);
475+
if (!position.hasPixels) break;
476+
final currentPixels = position.pixels;
477+
if ((currentPixels - lastPixels).abs() < 0.5) break;
478+
lastPixels = currentPixels;
479+
checks++;
480+
}
481+
}
482+
459483
@override
460484
int get hashCode => Object.hash(id, key);
461485

lib/src/tooltip/tooltip_content.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,12 @@ class ToolTipContent extends StatelessWidget {
101101
if (titleWidget != null) titleWidget,
102102
if (descriptionWidget != null) descriptionWidget,
103103
if (actionWidget != null &&
104-
tooltipActionConfig.position.isInsideVertical)
104+
tooltipActionConfig.position.isInsideVertical) ...[
105+
SizedBox(
106+
height: tooltipActionConfig.gapBetweenContentAndAction,
107+
),
105108
actionWidget,
109+
],
106110
],
107111
);
108112

@@ -116,6 +120,7 @@ class ToolTipContent extends StatelessWidget {
116120
final gap = SizedBox(
117121
width: tooltipActionConfig.gapBetweenContentAndAction,
118122
);
123+
119124
return Row(
120125
mainAxisSize: MainAxisSize.min,
121126
children: [

0 commit comments

Comments
 (0)