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

feat(pagination): hide 1 dot pagination #4786

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 42 additions & 43 deletions playground/core/index.html
Original file line number Diff line number Diff line change
@@ -1,49 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Swiper Playground</title>
<link rel="stylesheet" href="../../build/swiper-bundle.css" />
<meta name="viewport" content="width=device-width" />
</head>

<head>
<meta charset="UTF-8" />
<title>Swiper Playground</title>
<link rel="stylesheet" href="../../build/swiper-bundle.css" />
<meta name="viewport" content="width=device-width" />
</head>
<body>
<section class="swiper-container">
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
<div class="swiper-slide">Slide 4</div>
<div class="swiper-slide">Slide 5</div>
<div class="swiper-slide">Slide 6</div>
<div class="swiper-slide">Slide 7</div>
<div class="swiper-slide">Slide 8</div>
<div class="swiper-slide">Slide 9</div>
<div class="swiper-slide">Slide 10</div>
</section>
<a href="#" class="append-slide">Append</a>
<style>
body,
html {
padding: 0;
margin: 0;
position: relative;
height: 100%;
}

<body>
<section class="swiper-container">
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
<div class="swiper-slide">Slide 4</div>
<div class="swiper-slide">Slide 5</div>
<div class="swiper-slide">Slide 6</div>
<div class="swiper-slide">Slide 7</div>
<div class="swiper-slide">Slide 8</div>
<div class="swiper-slide">Slide 9</div>
<div class="swiper-slide">Slide 10</div>
</section>
<style>
body,
html {
padding: 0;
margin: 0;
position: relative;
height: 100%;
}

.swiper-container {
width: 100%;
height: 300px;
margin: 50px auto;
}

.swiper-slide {
background: #f1f1f1;
color: #000;
text-align: center;
line-height: 300px;
}
</style>
<script type="module" src="./main.js"></script>
</body>
.swiper-container {
width: 100%;
height: 300px;
margin: 50px auto;
}

.swiper-slide {
background: #f1f1f1;
color: #000;
text-align: center;
line-height: 300px;
}
</style>
<script type="module" src="./main.js"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions playground/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ window.swiper = new Swiper({
itemRoleDescriptionMessage: 'slide',
},
});

// eslint-disable-next-line no-restricted-globals
document.querySelector('.append-slide').addEventListener('click', (e) => {
e.preventDefault();
// eslint-disable-next-line no-restricted-globals
window.swiper.appendSlide('<div class="swiper-slide">Slide</div>');
});
4 changes: 4 additions & 0 deletions src/components/pagination/pagination.less
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
.swiper-pagination-clickable & {
cursor: pointer;
}

&:only-child {
display: none !important;
}
}
.swiper-pagination-bullet-active {
opacity: 1;
Expand Down
4 changes: 4 additions & 0 deletions src/components/pagination/pagination.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
.swiper-pagination-clickable & {
cursor: pointer;
}

&:only-child {
display: none !important;
}
}
.swiper-pagination-bullet-active {
opacity: 1;
Expand Down