Skip to content

Commit

Permalink
Improved screenshot taking policy in regards to screen loading period
Browse files Browse the repository at this point in the history
  • Loading branch information
stasgora committed May 23, 2021
1 parent 49ad5db commit 3f17191
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- **BREAKING**: `Detector.hasGlobalScope` renamed to `Detector.cumulative`
- **FIX**: popup interactions included in outputs from below them
- **FIX**: background could be captured before the route transition animation has ended
- **NEW**: improved screenshot taking policy in regards to screen loading period

# 0.3.3

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<a href="https://pub.dev/packages/round_spot"><img src="https://img.shields.io/pub/v/round_spot.svg?color=blueviolet" alt="Pub"></a>
<a href="https://github.com/stasgora/round-spot/actions"><img src="https://github.com/stasgora/round-spot/workflows/build/badge.svg" alt="build"></a>
<a href="https://github.com/tenhobi/effective_dart"><img src="https://img.shields.io/badge/style-effective_dart-40c4ff.svg" alt="style: effective dart"></a>
<a href="https://pub.dev/packages/round_spot/score"><img src="https://badges.bar/round_spot/likes" alt="likes"></a>
<a href="https://github.com/stasgora/round-spot/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT"></a>

<img src="https://raw.githubusercontent.com/stasgora/round-spot/master/assets/banner.png" style="width: 100%" alt="Banner"><br>
Expand Down
8 changes: 3 additions & 5 deletions lib/src/components/background_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,21 @@ class BackgroundManager {

/// Determines if its necessary to take a screenshot when event is recorded
void onEvent(Offset event, Session session, GlobalKey areaKey) {
if (session.background == null || _eventOutsideScreenshot(event, session)) {
var baseCheck = session.background == null || !session.scrollable;
if (baseCheck || _eventOutsideScreenshot(event, session)) {
_takeScreenshot(session, areaKey);
}
}

bool _eventOutsideScreenshot(Offset event, Session session) {
if (!session.scrollable) return false;
var offset = session.backgroundOffset;
return !(offset & session.bgSize!).contains(event);
return !(session.backgroundOffset & session.bgSize!).contains(event);
}

/// Captures a screenshot from a [RepaintBoundary] using its [GlobalKey]
/// It than joins it with the already assembled image
/// replacing the part that's underneath it
void _takeScreenshot(Session session, GlobalKey areaKey) async {
if (!session.scrollable) {
if (session.background != null) return;
session.background = await _captureImage(areaKey, session.pixelRatio);
return;
}
Expand Down

0 comments on commit 3f17191

Please sign in to comment.