Skip to content

Commit

Permalink
Bug Fix: tapping on content causes tilt when enableRevert or enableSe…
Browse files Browse the repository at this point in the history
…nsorRevert is false
  • Loading branch information
AmosHuKe committed Sep 20, 2023
1 parent 7af516c commit f6366c7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

See the [Migration Guide](guides/migration_guide.md) for the details of breaking changes between versions.

## Unreleased

### Fixes

- Fix tapping on content causes tilt when `enableRevert` or `enableSensorRevert` is false.

## 2.0.3

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tilt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class _TiltState extends State<Tilt> {
/// 是否还原的取值
final Offset position = _tiltConfig.enableRevert
? progressPosition(width, height, _initAreaProgress)
: offset;
: currentPosition;
currentPosition = position;
areaProgress = p2cAreaProgress(
width,
Expand Down
6 changes: 3 additions & 3 deletions lib/src/tilt_stream_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class _TiltStreamBuilderState extends State<TiltStreamBuilder> {
bool get enableStream => !disable;

/// 传感器平台支持
final bool canSensorsPlatformSupport = sensorsPlatformSupport();
bool canSensorsPlatformSupport = sensorsPlatformSupport();

/// Touch, Hover 的 Stream
late Stream<TiltStream> currentTiltStream;
Expand Down Expand Up @@ -84,7 +84,7 @@ class _TiltStreamBuilderState extends State<TiltStreamBuilder> {
gyroscopeEvents
.listen(
null,
onError: (_) => enableSensors = false,
onError: (_) => canSensorsPlatformSupport = false,
cancelOnError: true,
)
.cancel();
Expand Down Expand Up @@ -121,7 +121,7 @@ class _TiltStreamBuilderState extends State<TiltStreamBuilder> {
return StreamBuilder<TiltStream>(
stream: enableStream
? currentTiltStream.mergeAll([
if (canSensorsPlatformSupport && enableSensors)
if (canSensorsPlatformSupport && tiltConfig.enableGestureSensors)
currentGyroscopeStream,
]).map(filterTiltStream)
: null,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: Easily apply tilt parallax hover effects for Flutter, which support
# https://semver.org/spec/v2.0.0-rc.1.html
# https://dart.dev/tools/pub/versioning#semantic-versions
# https://dart.dev/tools/pub/dependencies#version-constraints
version: 2.0.3
version: 2.0.4
homepage: https://amoshuke.github.io/flutter_tilt_book
repository: https://github.com/AmosHuKe/flutter_tilt
issue_tracker: https://github.com/AmosHuKe/flutter_tilt/issues
Expand Down

0 comments on commit f6366c7

Please sign in to comment.