Skip to content

Commit 0ac1143

Browse files
committed
Allow fade transition with multiple visible slides & cleanup. :simple_smile:
1 parent 8439731 commit 0ac1143

File tree

8 files changed

+402
-139
lines changed

8 files changed

+402
-139
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ npm install vueperslides --save-dev
1616
> [https://antoniandre.github.io/vueper-slides](https://antoniandre.github.io/vueper-slides)
1717
1818
## Try it yourself
19-
> [https://codepen.io/antoniandre/pen/djMpxa](https://codepen.io/antoniandre/pen/djMpxa)
19+
> [https://codepen.io/antoniandre/pen/jevjoQ](https://codepen.io/antoniandre/pen/jevjoQ)
2020
2121
## Browser Support
2222
![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) |
@@ -29,6 +29,7 @@ ___
2929

3030
## Release Notes
3131

32+
- __Version 1.14.0__ Allow fade transition with multiple items per slide
3233
- __Version 1.13.0__ Allow multiple items per slide
3334
- __Version 1.12.0__ Add a 'no-shadow' class to remove default inner shadow
3435
- __Version 1.11.0__ Allow slide background inside slide container
@@ -42,9 +43,7 @@ ___
4243
- __Version 1.5.0__ Add transition speed param & slide content outside above or under slideshow
4344
- __Version 1.4.0__ Allow complex slide title & content
4445
- __Version 1.3.2__ Add option to place arrows outside. The config is now VueJS-reactive
45-
- __Version 1.3.1__ More options & improvements of parallax feature
4646
- __Version 1.3.0__ Add parallax feature
47-
- __Version 1.2.1__ Code cleanup, improvements & minor HTML structure change
4847
- __Version 1.2.0__ Add dragging distance feature
4948
- __Version 1.1.0__ Add breakpoints feature
5049
- __Version 1.0.0__ First public release

dist/vueperslides.js

Lines changed: 296 additions & 60 deletions
Large diffs are not rendered by default.

dist/vueperslides.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vueperslides.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

documentation/src/pages/main/template.pug

Lines changed: 59 additions & 45 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vueperslides",
3-
"version": "1.13.8",
3+
"version": "1.14.0",
44
"description": "A touch ready and responsive slideshow for Vue JS.",
55
"repository": "https://github.com/antoniandre/vueper-slides",
66
"author": "Antoni Andre <[email protected]>",

src/components/VueperSlide.vue

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<template lang="pug">
2-
div(:class="{ 'vueperslide': true, 'vueperslide--active': $parent.slides.activeUid === _uid }" :style="wrapperStyles" :aria-hidden="$parent.slides.activeUid === _uid ? 'false' : 'true'")
3-
div.vueperslide__image(v-if="image && $parent.conf.slideImageInside" :style="imageStyles")
4-
div.vueperslide__content-wrapper(v-show="!$parent.conf.slideContentOutside && (title || hasTitleSlotData || content || hasContentSlotData)")
5-
div.vueperslide__title(v-show="title || hasTitleSlotData")
2+
div(:class="{ 'vueperslide': true, 'vueperslide--active': $parent.slides.activeUid === _uid, 'vueperslide--visible': isSlideVisible }" :style="wrapperStyles" :aria-hidden="$parent.slides.activeUid === _uid ? 'false' : 'true'")
3+
.vueperslide__image(v-if="image && $parent.conf.slideImageInside" :style="imageStyles")
4+
.vueperslide__content-wrapper(v-show="!$parent.conf.slideContentOutside && (title || hasTitleSlotData || content || hasContentSlotData)")
5+
.vueperslide__title(v-show="title || hasTitleSlotData")
66
div(v-show="!$parent.conf.slideContentOutside && !title")
77
slot(name="slideTitle")
88
div(v-if="title" v-html="title")
9-
div.vueperslide__content(v-if="content || hasContentSlotData")
9+
.vueperslide__content(v-if="content || hasContentSlotData")
1010
div(v-show="!$parent.conf.slideContentOutside && !content")
1111
slot(name="slideContent")
1212
div(v-if="content" v-html="content")
@@ -46,19 +46,33 @@ export default {
4646
wrapperStyles () {
4747
return {
4848
...(!this.$parent.conf.slideImageInside && this.image && { backgroundImage: `url(http://github.com/%3Cspan%20class=%22pl-s1%22%3E%3Cspan%20class=%22pl-pse%22%3E$%7B%3C/span%3E%3Cspan%20class=%22pl-c1%22%3Ethis%3C/span%3E.%3Cspan%20class=%22pl-smi%22%3Eimage%3C/span%3E%3Cspan%20class=%22pl-pse%22%3E%7D%3C/span%3E%3C/span%3E)` }),
49-
...(this.$parent.conf.visibleSlides && { width: 100 / this.$parent.conf.visibleSlides + '%' })
49+
...(this.$parent.conf.visibleSlides && { width: 100 / this.$parent.conf.visibleSlides + '%' }),
50+
...(this.$parent.conf.visibleSlides > 1 && this.$parent.conf.fade && { left: ((this.slideIndex % this.$parent.conf.visibleSlides) / this.$parent.conf.visibleSlides) * 100 + '%' })
5051
}
5152
},
5253
imageStyles () {
5354
return { ...(this.$parent.conf.slideImageInside && this.image && { backgroundImage: `url(http://github.com/%3Cspan%20class=%22pl-s1%22%3E%3Cspan%20class=%22pl-pse%22%3E$%7B%3C/span%3E%3Cspan%20class=%22pl-c1%22%3Ethis%3C/span%3E.%3Cspan%20class=%22pl-smi%22%3Eimage%3C/span%3E%3Cspan%20class=%22pl-pse%22%3E%7D%3C/span%3E%3C/span%3E)` }) }
5455
},
55-
hasTitleSlotData () {
56-
let { slideTitle } = this.$slots
56+
hasTitleSlotData () {
57+
const { slideTitle } = this.$slots
5758
return slideTitle !== undefined
5859
},
59-
hasContentSlotData () {
60-
let { slideContent } = this.$slots
60+
hasContentSlotData () {
61+
const { slideContent } = this.$slots
6162
return slideContent !== undefined
63+
},
64+
isSlideVisible () {
65+
const activeSlideUid = this.$parent.slides.activeUid
66+
const activeSlideIndex = this.slidesList.indexOf(activeSlideUid)
67+
const visibleSlidesCount = this.$parent.conf.visibleSlides
68+
69+
return this.slideIndex >= activeSlideIndex && this.slideIndex < activeSlideIndex + visibleSlidesCount
70+
},
71+
slidesList () {
72+
return this.$parent.slides.list.map(slide => slide._uid)
73+
},
74+
slideIndex () {
75+
return this.slidesList.indexOf(this._uid)
6276
}
6377
}
6478
}
@@ -96,7 +110,7 @@ export default {
96110
opacity: 0;
97111
transition: .8s ease-in-out opacity;
98112
99-
&--active {
113+
&--active, &--visible {
100114
z-index: 1;
101115
opacity: 1;
102116
}

src/components/VueperSlides.vue

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<template lang="pug">
2-
div.vueperslides(:class="{ 'vueperslides--ready': isReady, 'vueperslides--fade': conf.fade, 'vueperslides--parallax': conf.parallax, 'vueperslides--touchable': touch.enabled && !disable, 'vueperslides--fixed-height': conf.fixedHeight, 'vueperslides--animated': transition.animated }" ref="vueperslides" aria-label="Slideshow" :style="vueperStyles")
3-
div.vueperslide__content-wrapper.vueperslide__content-wrapper--outside-top(:class="conf.slideContentOutsideClass" v-if="conf.slideContentOutside === 'top'")
4-
div.vueperslide__title(v-if="slides.count" v-html="getCurrentSlideData('title')")
5-
div.vueperslide__content(v-if="slides.count" v-html="getCurrentSlideData('content')")
6-
7-
div.vueperslides__inner
8-
div.vueperslides__parallax-wrapper(:style="'padding-bottom:' + (conf.slideRatio * 100) + '%'" aria-live="polite")
9-
div.vueperslides__track(:class="{ 'vueperslides__track--dragging': touch.dragging, 'vueperslides__track--mousedown': mouseDown }" :style="trackStyles" ref="track")
10-
div.vueperslides__track-inner(:style="trackInnerStyles")
2+
.vueperslides(:class="{ 'vueperslides--ready': isReady, 'vueperslides--fade': conf.fade, 'vueperslides--parallax': conf.parallax, 'vueperslides--touchable': touch.enabled && !disable, 'vueperslides--fixed-height': conf.fixedHeight, 'vueperslides--animated': transition.animated }" ref="vueperslides" aria-label="Slideshow" :style="vueperStyles")
3+
.vueperslide__content-wrapper.vueperslide__content-wrapper--outside-top(:class="conf.slideContentOutsideClass" v-if="conf.slideContentOutside === 'top'")
4+
.vueperslide__title(v-if="slides.count" v-html="getCurrentSlideData('title')")
5+
.vueperslide__content(v-if="slides.count" v-html="getCurrentSlideData('content')")
6+
7+
.vueperslides__inner
8+
.vueperslides__parallax-wrapper(:style="'padding-bottom:' + (conf.slideRatio * 100) + '%'" aria-live="polite")
9+
.vueperslides__track(:class="{ 'vueperslides__track--dragging': touch.dragging, 'vueperslides__track--mousedown': mouseDown }" :style="trackStyles" ref="track")
10+
.vueperslides__track-inner(:style="trackInnerStyles")
1111
vueper-slide.vueperslide--clone(v-if="slides.count && clones[0]" :clone="0" :title="clones[0].title" :content="clones[0].content" :image="clones[0].image" :style="clones[0].style" aria-hidden="true")
1212
div(v-if="clones[0].titleSlot" slot="slideTitle" v-html="clones[0].titleSlot")
1313
div(v-if="clones[0].contentSlot" slot="slideContent" v-html="clones[0].contentSlot")
@@ -16,9 +16,9 @@ div.vueperslides(:class="{ 'vueperslides--ready': isReady, 'vueperslides--fade':
1616
div(v-if="clones[1].titleSlot" slot="slideTitle" v-html="clones[1].titleSlot")
1717
div(v-if="clones[1].contentSlot" slot="slideContent" v-html="clones[1].contentSlot")
1818

19-
div.vueperslides__paused(v-if="$slots.pausedIcon")
19+
.vueperslides__paused(v-if="$slots.pausedIcon")
2020
slot(name="pausedIcon")
21-
div.vueperslides__arrows(:class="{ 'vueperslides__arrows--outside': conf.arrowsOutside }" v-if="conf.arrows && slides.count > 1 && !disable")
21+
.vueperslides__arrows(:class="{ 'vueperslides__arrows--outside': conf.arrowsOutside }" v-if="conf.arrows && slides.count > 1 && !disable")
2222
button.vueperslides__arrow.vueperslides__arrow--prev(@click="previous()" v-show="!arrowPrevDisabled" aria-label="Previous" @keyup.left="previous()" @keyup.right="next()")
2323
slot(name="arrowLeft")
2424
svg(viewBox="0 0 24 24")
@@ -27,15 +27,15 @@ div.vueperslides(:class="{ 'vueperslides--ready': isReady, 'vueperslides--fade':
2727
slot(name="arrowRight")
2828
svg(viewBox="0 0 24 24")
2929
path(d="M7.8,21c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l7.4-7.3L7,4.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l8.8,8.7l-8.8,8.7C8.3,20.9,8,21,7.8,21z")
30-
div.vueperslides__bullets(v-if="conf.bullets && slides.count > 1 && !disable && !conf.bulletsOutside" role="tablist" aria-label="Slideshow navigation")
30+
.vueperslides__bullets(v-if="conf.bullets && slides.count > 1 && !disable && !conf.bulletsOutside" role="tablist" aria-label="Slideshow navigation")
3131
button.vueperslides__bullet(:class="{ 'vueperslides__bullet--active': slides.current === i * conf.slideMultiple }" v-for="(item, i) in Math.ceil(slides.count / conf.slideMultiple)" :key="i" @click="goToSlide(i * conf.slideMultiple)" @keyup.left="previous()" @keyup.right="next()" ref="bullet")
3232
span {{ i + 1 }}
3333

34-
div.vueperslides__bullets.vueperslides__bullets--outside(v-if="conf.bullets && slides.count > 1 && !disable && conf.bulletsOutside")
34+
.vueperslides__bullets.vueperslides__bullets--outside(v-if="conf.bullets && slides.count > 1 && !disable && conf.bulletsOutside")
3535
button.vueperslides__bullet(:class="{ 'vueperslides__bullet--active': slides.current === i * conf.slideMultiple }" v-for="(item, i) in Math.ceil(slides.count / conf.slideMultiple)" :key="i" @click="goToSlide(i * conf.slideMultiple)" @keyup.left="previous()" @keyup.right="next()" ref="bullet")
3636
span {{ i + 1 }}
3737

38-
div.vueperslide__content-wrapper.vueperslide__content-wrapper--outside-bottom(:class="conf.slideContentOutsideClass" v-if="conf.slideContentOutside === 'bottom'")
38+
.vueperslide__content-wrapper.vueperslide__content-wrapper--outside-bottom(:class="conf.slideContentOutsideClass" v-if="conf.slideContentOutside === 'bottom'")
3939
div.vueperslide__title(v-if="slides.count" v-html="getCurrentSlideData('title')")
4040
div.vueperslide__content(v-if="slides.count" v-html="getCurrentSlideData('content')")
4141
</template>
@@ -805,13 +805,13 @@ export default {
805805
return conf
806806
},
807807
vueperStyles () {
808-
return /^-?\d/.test(this.conf.fixedHeight) ? 'height: ' + this.conf.fixedHeight : null
808+
return /^-?\d/.test(this.conf.fixedHeight) ? `height: ${this.conf.fixedHeight}` : null
809809
},
810810
trackStyles () {
811811
let styles = {}
812812
813813
if (this.conf.parallax) {
814-
styles.transform = 'translate3d(0, ' + this.parallaxData.translation + '%, 0)'
814+
styles.transform = `translate3d(0, ${this.parallaxData.translation}%, 0)`
815815
816816
// Increase browser optimizations by allocating more machine resource.
817817
// ! \\ To be used wisely so deactivate when not needed.
@@ -826,7 +826,7 @@ export default {
826826
styles.transitionDuration = this.transition.speed + 'ms'
827827
828828
if (!this.conf.fade) {
829-
styles.transform = 'translate3d(' + this.transition.currentTranslation + '%, 0, 0)'
829+
styles.transform = `translate3d(${this.transition.currentTranslation}%, 0, 0)`
830830
831831
// Increase browser optimizations by allocating more machine resource.
832832
// ! \\ To be used wisely so deactivate when not needed.

0 commit comments

Comments
 (0)