question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Base carousel view processors setting views to hidden, displays as blank views.

See original GitHub issue

Firstly, this is a question rather than an issue (Also possibly a mad rambling as I have been working on this issue for about a week). I have been using this control as a CarouselView in my current project.

We are using it to display a grid of items that can be resized, e.g, if we have 20 items in a 4x4 grid page we have 2 pages, one with 16 and the other with 4. We can then resize the grid to 5x5 where we just have one page in the carousel. These pages have some Skia components and a text label.

Anyway, I have noticed that if the user quickly swipes to the end of the carousel with a large data set then swipes back or changes the ItemSource after swiping, some pages can be hidden but have the right data bound to them. I checked on iOS using reveal to see the data is there but the view is hidden. I thought this might be the time taken to layout the view or some race condition with setting the view to visible. I have fixed this issue by stopping the processor from hiding the pages, e.g., using a custom CarouselView and passing in my custom processors which don’t set the IsVisible flag on any of the views like here.

I was just wondering if there is any reason to hide the views in the processors?

If anyone else has a similar issue this is what my processors look like:

public class CustomCarouselBackViewProcessor : BaseCarouselBackViewProcessor
{
    public override void HandleInitView(IEnumerable<View> views, CardsView cardsView, AnimationDirection animationDirection)
    {
        var view = views.FirstOrDefault();
        if (view != null)
        {
            view.TranslationX = Sign((int)animationDirection) * cardsView.Width;
        }
    }

    public override void HandlePanChanged(IEnumerable<View> views, CardsView cardsView, double xPos, AnimationDirection animationDirection, IEnumerable<View> inactiveViews)
    {
        if (animationDirection == AnimationDirection.Null)
        {
            return;
        }

        var value = Sign((int)animationDirection) * cardsView.Width + xPos;
        if (Abs(value) > cardsView.Width || (animationDirection == AnimationDirection.Prev && value > 0) || (animationDirection == AnimationDirection.Next && value < 0))
        {
            return;
        }

        var view = views.FirstOrDefault();
        if (view != null)
        {
            view.TranslationX = value;
        }
    }
}
public class CustomCarouselFrontViewProcessor : BaseCarouselFrontViewProcessor
{
    public override void HandlePanChanged(IEnumerable<View> views, CardsView cardsView, double xPos, AnimationDirection animationDirection, IEnumerable<View> inactiveViews)
    {
        var view = views.FirstOrDefault();
        var inactiveView = inactiveViews.FirstOrDefault();

        if (Abs(xPos) > cardsView.Width || (animationDirection == AnimationDirection.Prev && xPos < 0) || (animationDirection == AnimationDirection.Next && xPos > 0))
        {
            return;
        }

        if (animationDirection == AnimationDirection.Null)
        {
            xPos = Sign(xPos) * Min(Abs(xPos / 4), NoItemMaxPanDistance);
        }

        if (view != null)
        {
            view.TranslationX = xPos;
        }
    }
}

then just subclass CarouselView with a custom one:

public class CustomCarouselView : CarouselView
{
    public CustomCarouselView() : base(new CustomCarouselFrontViewProcessor(), new CustomCarouselBackViewProcessor())
    {
    }
}

Essentially just removing all the IsVisible calls

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
b099l3commented, Aug 30, 2018

Ah, we are only in Landscape for this project. Didn’t think about the orientation change. I will try to create a sample this week and add it to the samples, it is quite hard to recreate this issue.

0reactions
AndreiMisiukevichcommented, Aug 31, 2018

Probably, we can add a property for determining possibility to change IsVisible… really, don’t know

Read more comments on GitHub >

github_iconTop Results From Across the Web

Carousel widget
Showcase specific items in your catalog using a scrolling list of images in the carousel widget. You can use this base system widget...
Read more >
GitHub - dermotduffy/frigate-hass-card: A Lovelace ...
Frigate Lovelace Card. A full-featured Frigate Lovelace card: Live viewing of multiple cameras. Clips and snapshot browsing via mini-gallery.
Read more >
User manual - Milestone XProtect® Smart Client 2023 R2
Views and view groups (explained) ... Optimize the display for viewing video by hiding the main timeline ... to views. 67. Edit the...
Read more >
US8028250B2 - User interface having a carousel view for ...
A carousel view is described. In an implementation, a method includes determining a number of items that are included in data. A carousel...
Read more >
User manual - Milestone XProtect® Smart Client 2023 R1
XProtect Smart Client is a desktop application designed to help you manage and view video from the cameras that are connected to your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found