@jocampo3/slider 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/index.js +1 -6
- package/package.json +1 -1
- package/styles.css +1 -1
package/README.md
CHANGED
|
@@ -33,14 +33,14 @@ import '@jocampo3/slider/styles.css';
|
|
|
33
33
|
|
|
34
34
|
const interval = 3500; // update to your interval value
|
|
35
35
|
const slides = document.querySelectorAll('.slideshow');
|
|
36
|
-
const includeButtons = true; // creates pseudo buttons for better UI
|
|
37
36
|
|
|
38
|
-
slides.forEach(s => new Slider(s, interval
|
|
37
|
+
slides.forEach(s => new Slider(s, interval);
|
|
39
38
|
```
|
|
40
39
|
|
|
41
40
|
## Example
|
|
42
41
|
```html
|
|
43
|
-
|
|
42
|
+
<!-- NOTE: To enable buttons, include the 'js-buttons' class on the slideshow div -->
|
|
43
|
+
<div class="slideshow js-buttons">
|
|
44
44
|
<figure>
|
|
45
45
|
<!-- self-referenced link -->
|
|
46
46
|
<a id="a-classic" href="#a-classic">
|
package/index.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
export default class Slider {
|
|
2
|
-
constructor(slider, interval
|
|
2
|
+
constructor(slider, interval) {
|
|
3
3
|
this.slider = slider;
|
|
4
4
|
this.slides = this.slider.children;
|
|
5
5
|
this.index = 0;
|
|
6
6
|
this.interval = interval;
|
|
7
7
|
this.timer = null;
|
|
8
|
-
if (includeButtons === true) { this.addButtons(this.slider); }
|
|
9
8
|
this.restartTimer();
|
|
10
9
|
this.addListeners();
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
addButtons(slider) {
|
|
14
|
-
slider.classList.add('js-buttons');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
12
|
slideWidth() {
|
|
18
13
|
return this.slider.clientWidth;
|
|
19
14
|
}
|
package/package.json
CHANGED
package/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.slideshow :first-child a:before,.slideshow :last-child a:after,.slideshow:after,.slideshow:before{display:none}.slideshow,.slideshow>* a{width:100%;height:100%;display:flex}.slideshow.js-buttons::after,.slideshow.js-buttons::before{display:block;font-size:2em;background:#aaa;opacity:0.8;padding:8px 15px;border-radius:100%;position:absolute;top:50%;transform:translateY(-50%);cursor:pointer;z-index:5}.slideshow.js-buttons::before{content:'<';left:10px}.slideshow.js-buttons::after{content:'>';right:10px}a{text-decoration:none}.slideshow{overflow-x:scroll;overflow-y:hidden;scroll-snap-type:x mandatory;overscroll-behavior-x:contain;scrollbar-width:none}.slideshow::-webkit-scrollbar{display:none}.slideshow:hover{scroll-behavior:smooth}.slideshow>*{position:relative;scroll-snap-align:
|
|
1
|
+
.slideshow :first-child a:before,.slideshow :last-child a:after,.slideshow:after,.slideshow:before{display:none}.slideshow,.slideshow>* a{width:100%;height:100%;display:flex}.slideshow.js-buttons::after,.slideshow.js-buttons::before{display:block;font-size:2em;background:#aaa;opacity:0.8;padding:8px 15px;border-radius:100%;position:absolute;top:50%;transform:translateY(-50%);cursor:pointer;z-index:5;pointer-events:none;}.slideshow.js-buttons::before{content:'<';left:10px}.slideshow.js-buttons::after{content:'>';right:10px}a{text-decoration:none}.slideshow{overflow-x:scroll;overflow-y:hidden;scroll-snap-type:x mandatory;overscroll-behavior-x:contain;scrollbar-width:none;}.slideshow::-webkit-scrollbar{display:none}.slideshow:hover{scroll-behavior:smooth}.slideshow>*{position:relative;scroll-snap-align:center;flex-shrink:0;width:100%;height:100%;margin:0 15%}.slideshow>* a{align-items:center;justify-content:center;-webkit-tap-highlight-color:transparent}.slideshow a>*{max-width:100%;max-height:100%;object-fit:contain;z-index:1}.slideshow a:focus-visible{outline:0}.slideshow a:after,.slideshow a:before{z-index:2;content:"";display:block;position:absolute;top:0;bottom:0;width:calc(50% + 4vw)}.slideshow a:before{left:calc(-1 * calc(50% + 4vw))}.slideshow a:after{right:calc(-1 * calc(50% + 4vw))}
|