triniwiz / nativescript-pager

Apache License 2.0
90 stars 48 forks source link

Pager doesn't show up any pagerItem inside tabs component unless a travel to two tabs away then go back to the first one with the pager. #165

Open lostation opened 4 years ago

lostation commented 4 years ago

Make sure to check the demo app(s) for sample usage

I followed the example for angular static views definitions

Make sure to check the existing issues in this repository

Didn't find any kind of same issue

If the demo apps cannot help and there is no issue for your problem, tell us about it

Please, ensure your title is less than 63 characters long and starts with a capital letter.

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

Describe the steps to reproduce it.

Just put this into a component then add the component's selector into first tabStripItem of a Tabs

<GridLayout  backgroundColor="lightgray">
   <Pager (loaded)="onPagerLoaded($event)" #pager height="100%" width="100%" showIndicator="true" orientation="horizontal">
       <GridLayout *pagerItem backgroundColor="red"></GridLayout>
       <GridLayout *pagerItem backgroundColor="blue"></GridLayout>
        <GridLayout *pagerItem backgroundColor="yellow"></GridLayout> 
    </Pager>
</GridLayout>

I've tried to refresh, requestLayout, disabled, enabled... within onPagerLoaded callback

onPagerLoaded(args: EventData) { this.logger.debug('onPagerLoaded'); const pager = args.object as Pager;

    if (this.platformService.isAndroid)
    {
        pager.android.setNestedScrollingEnabled(true);
    }

    pager.selectedIndex = 0;
    pager.isEnabled = true;
    pager.cache = false;
    pager.canGoLeft = true;
    pager.canGoRight = true;
    pager.indicator = Indicator.Flat;
    pager.refresh();
    pager.resetNativeView();
    pager.requestLayout();
}

but it only shows first the gray background of the container... it only works if I go to two tabs away then going back to the first one...and then the pager is redrawn and shows up the slides...

Any idea how to force redrawing, reloading or whatever... ??? Thanks a lot Triniwiz ;)

lostation commented 4 years ago

UPDATE: Visibly...it's not related to the Tabs itself... I tried without and even without RadSidedrawer... Now I think it's maybe more related to lazy load from children routes.

The routing stack : root level > children route module as AppContainer with a Sidedrawer > children home module > then import module component with Tabs > in first tab component with the pager...

If I use Pager directly from root level...it works... I really don't understand what's Wong.

triniwiz commented 4 years ago

Interesting try adding some logs here see when that’s called also when is this called it should be fired for each static pager item

triniwiz commented 4 years ago

@lostation can you share a demo

lostation commented 4 years ago

Re Triniwiz, Sorry no I cannot share as it is a commercial private app. And I really don't have time to plunk anything.

Anyway... Further investigation... under a phone it works as it should ! So it is just under tablet and when it is located into sub component. I use the pager at different places but these are using the full width. So As you mentioned it related to the measurement in somehow. Cause first display...there's non pager...then when it's some kind of refresh...it appears.