Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrolling not working as expected on iOS devices #436

Closed
LukasBrits opened this issue Nov 25, 2024 · 0 comments
Closed

Scrolling not working as expected on iOS devices #436

LukasBrits opened this issue Nov 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@LukasBrits
Copy link

Description

On apple devices, scrolling does not work as expected when there is a target area with a listener in the Rive animation. Scrolling does not work when the swipe gesture starts on the target area, otherwise it works as expected. The same behaviour does not seem to occur on android devices.

Steps To Reproduce

  • Launch the app on a mobile emulator or physical iOS device.
  • Attempt to scroll by clicking and swiping from the rive animation click target area (indicated by text "Swipe Here" in the demo).

Source

scroll_test.zip

Expected behavior

Scrolling should work normally when a swipe gesture starts on a Rive animation's target area.

Device & Versions

  • Devices: iOS Simulator (iPhone 16 Pro), Iphone 15 Pro (physical device)
  • OS: iOS 18.1.1
  • Flutter Version:
Flutter 3.24.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision dec2ee5c1f (12 days ago) • 2024-11-13 11:13:06 -0800
Engine • revision a18df97ca5
Tools • Dart 3.5.4 • DevTools 2.37.3

Additional context

Demo flutter app main.dart file:
import 'package:flutter/material.dart';
import 'package:rive/rive.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late StateMachineController _controller;

  onInit(Artboard artboard) {
    _controller =
        StateMachineController.fromArtboard(artboard, 'State Machine 1')!;
    _controller.isActive = true;
    artboard.addController(_controller);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              ...List.generate(
                5,
                (index) => Center(
                  child: Padding(
                    padding: const EdgeInsets.only(bottom: 10.0),
                    child: Container(
                      color: Colors.green,
                      width: 200.0,
                      height: 100.0,
                    ),
                  ),
                ),
              ),
              SizedBox(
                width: 200.0,
                height: 200.0,
                child: RiveAnimation.asset(
                  'assets/scroll_test.riv',
                  onInit: onInit,
                ),
              ),
              const SizedBox(
                height: 10.0,
              ),
              ...List.generate(
                5,
                (index) => Center(
                  child: Padding(
                    padding: const EdgeInsets.only(bottom: 10.0),
                    child: Container(
                      color: Colors.blue,
                      width: 200.0,
                      height: 100.0,
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

@LukasBrits LukasBrits added the bug Something isn't working label Nov 25, 2024
@LukasBrits LukasBrits changed the title Scrolling not working on iOS devices when the swipe gesture starts on a Rive target area Scrolling not working as expected on iOS devices Nov 26, 2024
rive-engineering pushed a commit that referenced this issue Nov 27, 2024
Resolves #436, and
- https://rive.app/community/forums/support/fsnLLkXUaA62/flutter-scrolling-not-working-as-expected-on-mobile/ft3UcorwBVAf

Our web runtime has a `isTouchScrollEnabled`. This reproduces that behaviour.

```
  /// For Rive Listeners, allows scrolling behavior to still occur on Rive
  /// widgets when a touch/drag action is performed on touch-enabled devices.
  /// Otherwise, scroll behavior may be prevented on touch/drag actions on the
  /// widget by default.
  ///
  /// Default `false`.
```

I made some TODOs in the code for future considerations. We might want to opt in to give users more control over which gestures should be registered, and we can potentially be smart about doing this conditionally, depending on what the Rive graphic allows you to do. But this requires more investigation.

https://github.com/user-attachments/assets/81119bed-cb8a-4672-9559-d1c85832bad9

Diffs=
8d1fdd16ad feat: add isTouchScrollEnabled (#8651)

Co-authored-by: Gordon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant