Skip to content

Commit

Permalink
Introduce progressbarOpposite option
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Mar 27, 2018
1 parent 172f4c4 commit bc2dccd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
18 changes: 15 additions & 3 deletions src/components/pagination/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,19 @@ const Pagination = {
$el.find(`.${params.totalClass}`).text(total);
}
if (params.type === 'progressbar') {
let progressbarDirection;
if (params.progressbarOpposite) {
progressbarDirection = swiper.isHorizontal() ? 'vertical' : 'horizontal';
} else {
progressbarDirection = swiper.isHorizontal() ? 'horizontal' : 'vertical';
}
const scale = (current + 1) / total;
let scaleX = scale;
let scaleX = 1;
let scaleY = 1;
if (!swiper.isHorizontal()) {
if (progressbarDirection === 'horizontal') {
scaleX = scale;
} else {
scaleY = scale;
scaleX = 1;
}
$el.find(`.${params.progressbarFillClass}`).transform(`translate3d(0,0,0) scaleX(${scaleX}) scaleY(${scaleY})`).transition(swiper.params.speed);
}
Expand Down Expand Up @@ -198,6 +205,9 @@ const Pagination = {
params.dynamicMainBullets = 1;
}
}
if (params.type === 'progressbar' && params.progressbarOpposite) {
$el.addClass(params.progressbarOppositeClass);
}

if (params.clickable) {
$el.on('click', `.${params.bulletClass}`, function onClick(e) {
Expand Down Expand Up @@ -240,6 +250,7 @@ export default {
renderProgressbar: null,
renderFraction: null,
renderCustom: null,
progressbarOpposite: false,
type: 'bullets', // 'bullets' or 'progressbar' or 'fraction' or 'custom'
dynamicBullets: false,
dynamicMainBullets: 1,
Expand All @@ -250,6 +261,7 @@ export default {
totalClass: 'swiper-pagination-total',
hiddenClass: 'swiper-pagination-hidden',
progressbarFillClass: 'swiper-pagination-progressbar-fill',
progressbarOppositeClass: 'swiper-pagination-progressbar-opposite',
clickableClass: 'swiper-pagination-clickable', // NEW
lockClass: 'swiper-pagination-lock',
},
Expand Down
6 changes: 4 additions & 2 deletions src/components/pagination/pagination.less
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@
.swiper-container-rtl & .swiper-pagination-progressbar-fill {
transform-origin: right top;
}
.swiper-container-horizontal > & {
.swiper-container-horizontal > &,
.swiper-container-vertical > &.swiper-pagination-progressbar-opposite {
width: 100%;
height: 4px;
left: 0;
top: 0;
}
.swiper-container-vertical > & {
.swiper-container-vertical > &,
.swiper-container-horizontal > &.swiper-pagination-progressbar-opposite {
width: 4px;
height: 100%;
left: 0;
Expand Down

0 comments on commit bc2dccd

Please sign in to comment.