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

disable autoscroll #11

Conversation

lukepighetti
Copy link
Contributor

@lukepighetti lukepighetti commented Jun 7, 2022

This PR automatically disables autoscrolling if physics are NeverScrollableScrollPhysics. It also allows the developer to override this automatic behavior using the autoScroll argument on ReorderableGrid, SliverReorderableGrid, and ReorderableGridView

Issues

Resolves #10

Code

return ReorderableGrid(
  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
    crossAxisCount: widget.layout.crossAxisCount,
    childAspectRatio: widget.layout.childAspect,
    mainAxisSpacing: widget.layout.gap,
    crossAxisSpacing: widget.layout.gap,
  ),
  itemCount: 9,
  physics: const NeverScrollableScrollPhysics(), ///////////////////////
  itemBuilder: (context, i) {
    return ReorderableGridDragStartListener(
      key: ValueKey(i),
      index: i,
      child: Container(
        color: Colors.red,
        child: Text(i.toString()),
      ),
    );
  },
  onReorder: (i, j) {
    print('from $i to $j');
  },
);

Before

Screen.Recording.2022-06-07.at.8.14.31.AM.mov

After

Screen.Recording.2022-06-07.at.8.31.40.AM.mov

@lukepighetti lukepighetti marked this pull request as ready for review June 7, 2022 12:31
@codecov
Copy link

codecov bot commented Jun 7, 2022

Codecov Report

Merging #11 (7e456ae) into master (115465d) will increase coverage by 0.27%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #11      +/-   ##
==========================================
+ Coverage   80.99%   81.26%   +0.27%     
==========================================
  Files           2        2              
  Lines         484      491       +7     
==========================================
+ Hits          392      399       +7     
  Misses         92       92              
Impacted Files Coverage Δ
lib/src/reorderable_grid.dart 82.63% <100.00%> (+0.23%) ⬆️
lib/src/reorderable_grid_view.dart 76.57% <100.00%> (+0.42%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 115465d...7e456ae. Read the comment docs.

@casvanluijtelaar
Copy link
Owner

is there a thought process why autoScroll wasn't added to all gridview constructors?

@lukepighetti
Copy link
Contributor Author

I intended to, which did I miss? (There was a follow up commit to try to capture them all)

@casvanluijtelaar casvanluijtelaar merged commit 6a2c590 into casvanluijtelaar:master Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No way to disable auto-scroll
2 participants