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.

[Ionic v4] Allow swiper-pagination to be styled

See original GitHub issue

Ionic Info @ionic/angular: “4.0.0-beta.1”

Describe the Feature Request I would like to be able to style the swiper-pagination element of the slides

For example, in my v3 app, I display the pagination as progressbar at the bottom of the slides

Because of shadow dom, this isn’t possible anymore, a style like the following won’t be applied

div.swiper-pagination.swiper-pagination-progressbar {
    top: inherit;
    bottom: 0;
}

Related Code

slideOptsProgressbar: SwiperOptions = {
    pagination: {
        el: '.swiper-pagination',
        type: 'progressbar'
    }
};

<ion-slides pager="true" [options]="slideOptsProgressbar">
</ion-slides>

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
peterpeterparkercommented, Aug 25, 2018

Do you like hacks? Do you like having the pagination of your swiper positioned at the bottom of your slider but without touching the nested element?

Here you go: the tricks is to declare the swiper options as custom but to actually render a slider as progressBar but with a bottom position 😜

<ion-slides pager="true" [options]="slideOptsProgressbar">
</ion-slides>

 slideOptsProgressbar: SwiperOptions = {
    pagination: {
        el: '.swiper-pagination',
        type: 'custom',
        renderCustom: (swiper, current, total) => {
            return this.customProgressBar(current, total);
        }
    }
};

private customProgressBar(current: number, total: number): string {
    const ratio: number = current / total;

    const progressBarStyle: string = 'style=\'transform: translate3d(0px, 0px, 0px) scaleX(' + ratio + ') scaleY(1); transition-duration: 300ms;\'';
    const progressBar: string = '<span class=\'swiper-pagination-progressbar-fill\' ' + progressBarStyle + '></span>';

    let progressBarContainer: string = '<div class=\'swiper-pagination-progressbar\' style=\'height: 4px; top: 6px; width: 100%;\'>';
    progressBarContainer += progressBar;
    progressBarContainer += '</span></div>';

    return progressBarContainer;
}

enjoy

0reactions
ionitron-bot[bot]commented, Sep 24, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set Up Swiper.js for Angular Slides [Example] - Ionic Framework
Read this guide to learn how to get Swiper.js for Angular set up in your Ionic Framework application for a modern touch slider...
Read more >
How to use Swiper with Ionic (instead of ion-slides) - YouTube
In this video we will implement the Swiper component without ion -slides, since it will be deprecated with Framework v6! Learn...
Read more >
Ionic - Pagination is being hidden with new ion-slides ...
What I did was create my own custom pagination as this way the ng-hide class doesn't get added, luckily Swiper allows you to...
Read more >
Ionic 6 Slides using Swiper.js Tutorial by Examples
Step 1 – Install Required Packages · Step 2 – Import SwiperModule · Step 3 – Add SCSS Style Swiper Libs · Step...
Read more >
Swiper API
swiper /css - all Swiper styles including all modules styles (like Navigation, Pagination, etc.) swiper/css/bundle - same as previous but minified.
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