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

pageIndicators not showing #5

Open
zoeitsolutions opened this issue Jan 10, 2017 · 48 comments
Open

pageIndicators not showing #5

zoeitsolutions opened this issue Jan 10, 2017 · 48 comments

Comments

@zoeitsolutions
Copy link

zoeitsolutions commented Jan 10, 2017

Thanks for the plugin, I can't get the pageIndicators to show.

I followed the readme:

Indicators

If the property pageIndicators is true you won't see the page indicators anymore as of 2.0.0 right away. there are two css classes exposed that you can setup however you like for active and inactive indicators. below is an example for semi translucent dots.

.slide-indicator-inactive{
    background-color: #fff;
    opacity : 0.4;
    width : 10;
    height : 10;
    margin-left : 2.5;
    margin-right : 2.5;
    margin-top : 0;
    border-radius : 5;
}

.slide-indicator-active{
    background-color: #fff;
    opacity : 0.9;
    width : 10;
    height : 10;
    margin-left : 2.5;
    margin-right : 2.5;
    margin-top : 0;
    border-radius : 5;
}

I simply copied and pasted those into my slide.component.css file (which holds other classes for the component).

The other classes do pick up, I have tried setting the page bg to white or dark colours, but I still can't see any dots.

slide.component.html

<GridLayout columns="*" rows="*, auto" class="slide-bg"> <StackLayout col="0" row="0"> <slides [loop]="false" [pageIndicators]="true" class="slide-bg"> <slide class="slide-1"> <Label text="Heading 1" class="slide-heading h1"></Label> <Image src="https://placeholdit.imgix.net/~text?txtsize=19&bg=ffffff&txt=200%C3%97200&w=200&h=200"></Image> </slide> <slide class="slide-2"> <Label text="Heading 2" class="slide-heading h1"></Label> <Image src="https://placeholdit.imgix.net/~text?txtsize=19&bg=ffffff&txt=200%C3%97200&w=200&h=200"></Image> </slide> <slide class="slide-3"> <Label text="Heading 3" class="slide-heading h1"></Label> <Image src="https://placeholdit.imgix.net/~text?txtsize=19&bg=ffffff&txt=200%C3%97200&w=200&h=200"></Image> </slide> </slides> </StackLayout> <StackLayout col="0" row="1"> <Button text="Get Started" class="submit-button h2" height="80" (tap)="goToLogin()"></Button> </StackLayout> </GridLayout>

I have tried with and without the gridlayout / button at the bottom of the page. I have also tried increasing the size of the pageIndicators and removing opacity without any luck.

Thoughts?

@YvesCandel
Copy link

I'm having the same problem. Can't get them to show in any way.

@smarza
Copy link

smarza commented Jan 21, 2017

Me too.

@zoeitsolutions
Copy link
Author

@TheOriginalJosh please let me know if you are able to fix this or advise what the problem might be.

@smarza
Copy link

smarza commented Jan 23, 2017

If I set <slides [pageIndicators]="true">, i get the following error:

JS: clipToBounds with value false is not supported on Android. You can use this.android.getParent().setClipChildren(false) as an alternative.

Does anyone have any idea how to fixed this issue ?

Thanks in advance.

@JoshDSommer
Copy link
Owner

@smarza I'll fix this tonight.

@smarza
Copy link

smarza commented Jan 24, 2017

@TheOriginalJosh Thanks.
If there is anything I can help or contribute, please let me know.

@zoeitsolutions
Copy link
Author

@TheOriginalJosh was this fixed?

@pette9
Copy link

pette9 commented Feb 16, 2017

I am experiencing this problem on version 0.0.9.

@gauravbabu74
Copy link

I'm having the same problem. Can't get them to show in any way.

@cmeijerink
Copy link

Same issue here!

@JoshDSommer
Copy link
Owner

I'll look into this tonight

@Jaishankarb
Copy link

@TheOriginalJosh any update on this issue

@JoshDSommer
Copy link
Owner

@Jaishankarb not yet, I haven't had much free time to dedicate to it unfortunately.

@dobjek
Copy link
Contributor

dobjek commented Jun 12, 2017

any update on this issue?

@ivanwitzke
Copy link

same problem here...

@JoshDSommer
Copy link
Owner

JoshDSommer commented Jun 20, 2017

these should be working now for android and ios version 1.4. going to close this one. if you have any problems don't hesitate to open back up.

@carlosanjos
Copy link

Sorry @TheOriginalJosh I've just updated to 0.1.4 and the indicators are still now showing, for both iOS and Android.

@JoshDSommer
Copy link
Owner

JoshDSommer commented Jun 21, 2017

@carlosanjos page indicators are not on by default. You will need to make to set the property pageIndicators to true like this:

    <slides loop="true" [pageIndicators]="true">
        <slide class="slide-1">
            <Label text="Slide 1" textWrap="true"></Label>

and then add styling for them in your app.css or component css.

   background-color: #fff;
   opacity : 0.4;
   width : 10;
   height : 10;
   margin-left : 2.5;
   margin-right : 2.5;
   margin-top : 0;
   border-radius : 5;
}

.slide-indicator-active{
   background-color: #fff;
   opacity : 0.9;
   width : 10;
   height : 10;
   margin-left : 2.5;
   margin-right : 2.5;
   margin-top : 0;
   border-radius : 5;
}

without both of these steps. page indicators won't display.

@carlosanjos
Copy link

@TheOriginalJosh I'm using the following code and it doesn't work.
Thanks for the fast reply.

<slides [loop]="false" [pageIndicators]="true" class="slide-bg">
    <slide class="slide-1"><Label text="Heading 1" class="slide-heading h1"></Label>
        <Image src="https://placeholdit.imgix.net/~text?txtsize=19&bg=ffffff&txt=200%C3%97200&w=200&h=200"></Image>
    </slide>
    <slide class="slide-2"><Label text="Heading 2" class="slide-heading h1"></Label>
        <Image src="https://placeholdit.imgix.net/~text?txtsize=19&bg=ffffff&txt=200%C3%97200&w=200&h=200"></Image>
    </slide>
    <slide class="slide-3"><Label text="Heading 3" class="slide-heading h1"></Label>
        <Image src="https://placeholdit.imgix.net/~text?txtsize=19&bg=ffffff&txt=200%C3%97200&w=200&h=200"></Image>
    </slide>
</slides>
.slide-1{
    background-color: darkslateblue;
}
.slide-2{
    background-color: darkcyan;
}
.slide-3{
    background-color: darkgreen;
}
Label{
    text-align: center;
    width: 100%;
    font-size: 35;
    margin-top: 35;
    color: red;

}

.slide-indicator-inactive{
    background-color: #fff;
    opacity : 0.4;
    width : 10;
    height : 10;
    margin-left : 2.5;
    margin-right : 2.5;
    margin-top : 0;
    border-radius : 5;
}

.slide-indicator-active{
    background-color: #fff;
    opacity : 0.9;
    width : 10;
    height : 10;
    margin-left : 2.5;
    margin-right : 2.5;
    margin-top : 0;
    border-radius : 5;
}

screen shot 2017-06-21 at 16 53 38

@JoshDSommer
Copy link
Owner

@carlosanjos I just tested your code on an android emulator and I'm seeing the background color and the slide indicators. I'm not on a mac at the moment so I can't test on an ios emulator. but it seems that the background colors are not showing up correctly for you. maybe try changing them to a hexadecimal color like #000?

image

@dobjek
Copy link
Contributor

dobjek commented Jun 23, 2017

Doesn't show for me either. I have image as the component's background, might that be a problem?

@JoshDSommer
Copy link
Owner

@dobjek it very well could be the image. that is something I haven't really thought of . if you put the default code in from the README do the indicators show up?

@JoshDSommer JoshDSommer reopened this Jun 23, 2017
@sittingbool
Copy link

sittingbool commented Jun 23, 2017

I just started the demo project, added the styles to the app.css but no indicators showing up. (set the property to true of course). Running on iOS.

@JoshDSommer
Copy link
Owner

@sittingbool make sure you set the pageIndicators property to true in the slides component
<slides [pageIndicators]="true" class="slide-bg">

@JoshDSommer
Copy link
Owner

@sittingbool alternatively it could be an issue with the slides being generated in a ngFor loop in the demo project. you may want to try have the slides statically defined and see if that works.

@sittingbool
Copy link

I had this property on true, I also had a colored background. But still not showing. Also I tried doing the slides manually, because that would be my use case. Didn't work. If I find the time I will work on this and give you a pull request. Tell me if you find the time to have a look.

@JoshDSommer
Copy link
Owner

@sittingbool What version of NativeScript and Angular are you running?

@sittingbool
Copy link

The latest NativeScript (3.0.3) and Angular like in the package.json of the demo App. I used the demo App provided by this repository. I downloaded as a zip, changed the absolute path to the slides-project into a relative path, added [pageIndicators]="true", the css like in the readme and ran it with tns run ios. No indicators visible. Then I added background-color but still: no indicators visible.

@JoshDSommer
Copy link
Owner

@sittingbool one thing you may want to try doing is setting the margin-top property to a lower or negative number. the positioning top seems to be inconsistent and I'm going to need to work on it.

@dobjek
Copy link
Contributor

dobjek commented Jun 28, 2017

i believe this is why we are not seeing those pageIndicators:
NativeScript/nativescript-angular#769

@dobjek
Copy link
Contributor

dobjek commented Jun 28, 2017

so, temp workaround is to put .slide-indicator-inactive and .slide-indicator-active to your app.css

@ivanwitzke
Copy link

For me it 'kinda' works with the code like this (and css as the doc examples on my app.css):

<GridLayout rows="10, auto" columns="50, auto">
    <Label text="Photos" row="0" col="0"></Label>
    <StackLayout row="1" colSpan="2">
        <slides [pageIndicators]="true">
            <slide *ngFor="let photo of product.photos" class="slide-bg">
                <FrescoDrawee [imageUri]="photo" height="250" actualImageScaleType="fitCenter"></FrescoDrawee>
            </slide>
        </slides>
    </StackLayout>
</GridLayout>

but the result is like the images below...
whatsapp image 2017-07-07 at 17 44 08 1
whatsapp image 2017-07-07 at 17 44 08

@JoshDSommer
Copy link
Owner

@ivanwitzke Thank you for the info. this makes sense since i'm calculating the position of the indicators based on the view height not the height of the slides themselves. going to have to go back to the drawing board on this I think.

@ivanwitzke
Copy link

ivanwitzke commented Jul 9, 2017 via email

@KBorecki
Copy link

Hey @TheOriginalJosh is there any update of this issue?

@JoshDSommer
Copy link
Owner

JoshDSommer commented Jul 20, 2017

@KBorecki , @dobjek made a PR (#28) to fix this a while ago and I've currently published it under a beta tag. You can install it with npm install nativescript-ngx-slides@beta. any feed back would be helpful.

@ivanwitzke
Copy link

Unfortunatelly for me nothing has changed... If the device is on vertical, the indicators won't show, but if I rotate to horizontal, then they appear.
The basic structure of the view is:

StackLayout -> ScrollView -> CardView -> GridLayout -> StackLayout ->

<slides [pageIndicators]="true">
    <slide *ngFor="let photo of product.photos" class="slide-bg">
        <FrescoDrawee [imageUri]="photo" height="250" actualImageScaleType="fitCenter"></FrescoDrawee>
    </slide>
</slides>

@JoshDSommer
Copy link
Owner

@ivanwitzke this is installed from the beta tag? npm install nativescript-ngx-slides@beta?

@ivanwitzke
Copy link

ivanwitzke commented Jul 20, 2017

@TheOriginalJosh yes... but I just noticed that after installing from the beta tag (npm install nativescript-ngx-slides@beta), the console shows

/the/path/to/my/project
└── nativescript-ngx-slides@0.3.1

is this correct?

@JoshDSommer
Copy link
Owner

@ivanwitzke yep that is correct. Thanks for the info.

@ivanwitzke
Copy link

After setting the pageHeigth property in the <slides> the indicators show now, but if I rotate the device, then rotate it back, they won't show until I navigate away and come back to the page...

<slides [pageIndicators]="true" pageHeight="350">
    [more code here...]
</slides>

@sittingbool
Copy link

Now setting a negative top margin for the slide-indicator-inactive and slide-indicator-active classes shows the indicators on ios, while a zero top margin shows it on android. i suggest to use an absolute positioning to make sure its on top of the slides as well.

@nikunjgajera
Copy link

I have same issues, I cant get page indicator

slides.html

<slides [pageIndicators]="true" id="slides" #slides pageHeight="420">
    <slide *ngFor="let page of noOfPage">
        
        <StackLayout >
            <GridLayout rows="*,*,*,*,*,*" cols="10,16,16,16,16,16,10" >
            [Some Code....]
            </GridLayout>
      </StackLayout>
    </slide>
</slides>

slides.component.ts


export class SlidesComponent implements OnInit {
    players : Array<Player> = [];
   constructor(private router: Router, private page: Page) {
    }
    @ViewChild("slides") slides: ElementRef;
    ngOnInit() {
        this.page.actionBarHidden = true;
        this.page.backgroundImage = "res://hurling";
    }
    handlePlayer() {
        //Call api and get data
        this.players = data;
    }    
   ngAfterViewInit() {

        this.handlePlayer();
    }
}

slides.common.css

.slide-indicator-inactive{
    background-color: #000;
    opacity : 0.4;
    width : 10;
    height : 10;
    margin-left : 2.5;
    margin-right : 2.5;
    margin-top : 0;
    border-radius : 5;
}

.slide-indicator-active{
    background-color: #000;
    opacity : 0.9;
    width : 10;
    height : 10;
    margin-left : 2.5;
    margin-right : 2.5;
    margin-top : 0;
    border-radius : 5;
}

how can i get page indicator?

@heese
Copy link

heese commented Feb 9, 2018

I had also problems with the page indicators. They are perfectly fine when starting the app. However, they disappeared when resuming my app from the background.

I had to change the code of the plugin to make it work. I found that setting the top margin does funny stuff when resuming from background. I did not investigate why. I changed the following line in buildFooter() from
footerSection.marginTop = this.footerMarginTop;
to
footerSection.top = this.footerMarginTop;

For my app I changed also the formula for computing marginTop (otherwise the footer was too low when setting pageHeight). New formula is
return pageHeight - (pageHeight / 6) - this.FOOTER_HEIGHT / 2;

I have not tested if the above formula works also for other page heights.

Here is another fix I applied to make page indicators working on Android. I added another StackLayout around the label. The new template is

<StackLayout *ngIf="pageIndicators" #footer style="width:100%;" orientation="horizontal">
    <StackLayout *ngFor="let indicator of indicators">
        <Label [class.slide-indicator-active]="indicator.active == true"
               [class.slide-indicator-inactive]="indicator.active == false"></Label>
    </StackLayout>
</StackLayout>

I haven't tested if it would work without the additional stack layout after applying the margin fix.

Still waiting for a spare time-slot to create a pull request and do more testing :-|

@anuragd7
Copy link

I too faced quite a few problems in making the page indicators appear. Finally, I experimented with different values of pageHeight and footerMarginTop properties and what worked for me was:

<GridLayout  rows="50% *" >
        <slides row="0" [pageIndicators]="true" pageHeight="80%" footerMarginTop="70%">

@vahidvdn
Copy link
Contributor

vahidvdn commented Aug 3, 2018

I just added theses css codes in my app.android.css:

.slide-indicator-inactive{
    background-color: #000;
    opacity : 0.4;
    width : 10;
    height : 10;
    margin-left : 2.5;
    margin-right : 2.5;
    margin-top : 0;
    border-radius : 5;
}

.slide-indicator-active{
    background-color: #000;
    opacity : 0.9;
    width : 10;
    height : 10;
    margin-left : 2.5;
    margin-right : 2.5;
    margin-top : 0;
    border-radius : 5;
}

This must be mentioned in the docs.

@vahidvdn
Copy link
Contributor

Also you must set footerMarginTop property to something less than 100%. For example:

footerMarginTop="80%"

@KirilOkun
Copy link

Setting .slide-indicator-inactive and .slide-indicator-active margin-top: -1; and <slides ... pageHeight="100%"> worked for me. The indicators showed up but at the top of the page above the slides. Better than nothing i suppose.

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

No branches or pull requests