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

ItemPosition doesn't give enough information #97

Open
marcglasberg opened this issue Apr 17, 2020 · 3 comments
Open

ItemPosition doesn't give enough information #97

marcglasberg opened this issue Apr 17, 2020 · 3 comments
Labels
enhancement New feature or request p: scrollable_positioned_list Related to package:scrollable_positioned_list SPL-pixels Issues asking for pixel level info or control

Comments

@marcglasberg
Copy link

marcglasberg commented Apr 17, 2020

The is the current provided information:

const ItemPosition(
{@required this.index,
@required this.itemLeadingEdge,
@required this.itemTrailingEdge});

This is not nearly enough for all kinds of applications. For example, with the above info I can't implement a multi-item sticky-headers.

It should be:

  const ItemPosition(
      {@required this.index,
      @required this.leadingAlignment,
      @required this.trailingAlignment,
      @required this.leadingPixelDistance,
      @required this.trailingPixelDistance,
      @required this.length,
});

Also, how can I get the length of the viewport?

@jamesderlin jamesderlin added p: scrollable_positioned_list Related to package:scrollable_positioned_list enhancement New feature or request labels Apr 17, 2020
@tarobins
Copy link
Collaborator

Can you define each of the items proposed below?

const ItemPosition(
{@required this.index,
@required this.leadingAlignment,
@required this.trailingAlignment,
@required this.leadingPixelDistance,
@required this.trailingPixelDistance,
@required this.length,
});

How would you be using these to implement something like https://pub.dev/packages/sticky_headers?

@marcglasberg
Copy link
Author

marcglasberg commented May 4, 2020

  • leadingAlignment ➜ Your old itemLeadingEdge
  • trailingAlignment ➜ Your old itemTrailingEdge
  • leadingPixelDistance ➜ The distance, in pixels, from the screen edge to the item's leading edge.
  • trailingPixelDistance ➜ The distance, in pixels, from the screen edge to the item's trailing edge.
  • length ➜ The size (height or width) of the item in the viewport's direction.

@tarobins tarobins added SPL-pixels Issues asking for pixel level info or control and removed SPL-waiting for response labels May 11, 2020
@marcglasberg
Copy link
Author

marcglasberg commented May 13, 2020

I edited the issue to remove the reference to https://pub.dev/packages/sticky_headers. In fact, that package in particular does work for ScrollablePositionedList, because ScrollablePositionedList uses two regular scrolls, and that StickyHeaders can get the necessary pixel position from these.

In any case, there are other uses for knowing the exact pixel distances, instead of only the alignment. For example, I want to create another kind of StickyHeader that spans multiple items.

This is what I am trying to do to implement a sticky header in a vertical scroll:

  1. Put the list inside of a Stack.
  2. When the leadingPixelDistance of the item at the top is positive or zero, I don't and a header to it.
  3. When the leadingPixelDistance is negative (meaning that part of the item is out of the screen), I add the header. This means the header will start to overlap the content.
  4. When the item is going out of the screen, so that the header doesn't fit anymore, the header needs to start moving out as well, by the same number of pixels.

I can't do that without the pixel information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request p: scrollable_positioned_list Related to package:scrollable_positioned_list SPL-pixels Issues asking for pixel level info or control
Projects
None yet
Development

No branches or pull requests

3 participants