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

Vertical scrolling while dragging the event #128

Open
HaneenAhmedMohy opened this issue Aug 7, 2022 · 3 comments
Open

Vertical scrolling while dragging the event #128

HaneenAhmedMohy opened this issue Aug 7, 2022 · 3 comments
Labels
T: Fix Type: :bug: Bug Fixes

Comments

@HaneenAhmedMohy
Copy link

using the dateController.animateToPage is smooth in scrolling horizontally while dragging the event but using the timeController.animateTo to scroll vertically has a slow and weird behavior while dragging ... any help, please ?

@HaneenAhmedMohy HaneenAhmedMohy added the T: Fix Type: :bug: Bug Fixes label Aug 7, 2022
@JonasWanke
Copy link
Owner

Can you please add some code to demonstrate the problem you're facing and, preferably, a video/GIF of the behavior?

@HaneenAhmedMohy
Copy link
Author

HaneenAhmedMohy commented Aug 8, 2022

We are using LongPressDraggable to drag and drop the event

Positioned(
      top: _top
      left: _left
      child: LongPressDraggable(
        onDragUpdate: _onDragUpdate,
        childWhenDragging: Opacity(opacity: 0.75, child: _buildPicker()),
        feedback: Container(),
        child: _buildPicker(),
      ),
    );

and onDrag update we are calling this function

void _onDragUpdate(DragUpdateDetails details) {
    setState(() {
      _left += details.delta.dx;
      _top+=details.delta.dy
    });
    _moveCanvasVertically();
    _maybeMoveCanvasHorizontally();
  }

and here are the vertical and horizontal dragging methods

void _maybeMoveCanvasHorizontally() async {
    final page = widget.dateController.value.page;
    final daysCount = widget.dateController.visibleRange.visibleDayCount;
    final quarterOfWidth = widget.width / 4;
    if (_animating) return;
    if (_left >= widget.width * (daysCount - 1) + quarterOfWidth) {
      _animating = true;
      await widget.dateController.animateToPage(
        page + daysCount,
        vsync: this,
        duration: const Duration(milliseconds: 400),
      );
      _animating = false;
    } else if (_left < 0 - quarterOfWidth) {
      _animating = true;
      await widget.dateController.animateToPage(
        page - daysCount,
        vsync: this,
        duration: const Duration(milliseconds: 400),
      );
      _animating = false;
    }
  }
Future<void> _moveCanvasVertically() async {
    _animating = true;
    await widget.timeController.animateTo(
      TimeRange.centeredAround(
        _selectedStartDate.durationSinceStartOfDay,
        widget.timeController.value.duration,
      ),
      vsync: this,
      duration: const Duration(milliseconds: 400),
    );
    _animating = false;
  }

@HaneenAhmedMohy
Copy link
Author

Screen_Recording_20220807-231718.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: Fix Type: :bug: Bug Fixes
Projects
None yet
Development

No branches or pull requests

2 participants