PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 4.2.4
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v4.2.4
4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / assets / js / carousel.js
embedpress / assets / js Last commit date
vendor 7 years ago admin.js 1 year ago ads.js 1 year ago carousel.js 1 year ago carousel.min.js 2 years ago documents-viewer-script.js 3 years ago embed-ui.min.js 1 year ago front.js 1 year ago gallery-justify.js 1 year ago glider.js 1 year ago glider.min.js 2 years ago gutneberg-script.js 1 year ago index.html 7 years ago initCarousel.js 2 years ago initplyr.js 2 years ago instafeed.js 2 years ago license.js 2 years ago pdfobject.js 1 year ago plyr.js 1 year ago plyr.polyfilled.js 3 years ago preview.js 3 years ago settings.js 6 years ago vimeo-player.js 2 years ago ytiframeapi.js 2 years ago
carousel.js
208 lines
1 window.CgCarousel = class {
2 constructor(t, i = {}, e = []) {
3 (this.container = document.querySelector(t)),
4 this.container &&
5 ((this.slidesSelector = i.slidesSelector || ".js-carousel__slide"),
6 (this.trackSelector = i.trackSelector || ".js-carousel__track"),
7 (this.slides = []),
8 (this.track = this.container.querySelector(this.trackSelector)),
9 (this.slidesLength = 0),
10 (this.currentBreakpoint = void 0),
11 (this.breakpoints = i.breakpoints || {}),
12 (this.hooks = e),
13 (this.initialOptions = { loop: i.loop || !1, autoplay: i.autoplay || !1, autoplaySpeed: i.autoplaySpeed || 3e3, transitionSpeed: i.transitionSpeed || 650, slidesPerView: i.slidesPerView || 1, spacing: i.spacing || 0 }),
14 (this.options = this.initialOptions),
15 (this.animationStart = void 0),
16 (this.animation = void 0),
17 (this.animationCurrentTrans = 0),
18 (this.animationIndex = 0),
19 (window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame),
20 (window.cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame),
21 (this.autoplayInterval = void 0),
22 (this.isButtonRightDisabled = !1),
23 (this.isButtonLeftDisabled = !1),
24 (this.currentIndex = 0),
25 (this.maxIndex = 0),
26 (this.isInfinite = !1),
27 (this.isPrevInfinite = !1),
28 (this.swipeStartX = void 0),
29 (this.swipeStartY = void 0),
30 (this.swipeThreshold = 100),
31 (this.swipeRestraint = 100),
32 (this.swipeDir = void 0),
33 this.track && (this.addEventListeners(), this.initCarousel()));
34 }
35 hook(t) {
36 this.hooks[t] && this.hooks[t](this);
37 }
38 isTouchableDevice() {
39 return window.matchMedia("(pointer: coarse)").matches;
40 }
41 handleSwipe() {
42 switch (this.swipeDir) {
43 case "top":
44 case "bottom":
45 default:
46 break;
47 case "left":
48 this.next();
49 break;
50 case "right":
51 this.prev();
52 }
53 }
54 onSwipeStart(t) {
55 if (!this.isTouchableDevice() || !t.changedTouches) return;
56 const i = t.changedTouches[0];
57 (this.swipeStartX = i.pageX), (this.swipeStartY = i.pageY);
58 }
59 setSwipeDirection(t) {
60 const i = t.changedTouches[0],
61 e = i.pageX - this.swipeStartX,
62 s = i.pageY - this.swipeStartY;
63 Math.abs(e) >= this.swipeThreshold && Math.abs(s) <= this.swipeRestraint
64 ? (this.swipeDir = e < 0 ? "left" : "right")
65 : Math.abs(s) >= this.swipeThreshold && Math.abs(e) <= this.swipeRestraint && (this.swipeDir = s < 0 ? "up" : "down");
66 }
67 onSwipeMove(t) {
68 this.isTouchableDevice() && t.changedTouches && (this.setSwipeDirection(t), ["left", "right"].includes(this.swipeDir) && t.cancelable && t.preventDefault());
69 }
70 onSwipeEnd(t) {
71 this.isTouchableDevice() && t.changedTouches && (this.setSwipeDirection(t), this.handleSwipe());
72 }
73 addEventListeners() {
74 window.addEventListener("orientationchange", () => this.onResize()),
75 window.addEventListener("resize", () => this.onResize()),
76 this.container.addEventListener("touchstart", (t) => this.onSwipeStart(t), { passive: !0 }),
77 this.container.addEventListener("touchmove", (t) => this.onSwipeMove(t), !1),
78 this.container.addEventListener("touchend", (t) => this.onSwipeEnd(t), { passive: !0 });
79 }
80 onResize() {
81 this.checkBreakpoint() && this.buildCarousel(), this.hook("resized");
82 }
83 setUpAutoplay() {
84 this.options.autoplay && (clearInterval(this.autoplayInterval), (this.autoplayInterval = setInterval(() => this.next(), this.options.autoplaySpeed)));
85 }
86 checkBreakpoint() {
87 if (!this.breakpoints) return;
88 const t = Object.keys(this.breakpoints)
89 .reverse()
90 .find((t) => {
91 const i = `(min-width: ${t}px)`;
92 return window.matchMedia(i).matches;
93 });
94 if (this.currentBreakpoint === t) return;
95 this.currentBreakpoint = t;
96 const i = t ? this.breakpoints[t] : this.initialOptions;
97 return (this.options = { ...this.initialOptions, ...i }), !0;
98 }
99 setButtonsVisibility() {
100 (this.isButtonLeftDisabled = !this.options.loop && 0 === this.currentIndex), (this.isButtonRightDisabled = !this.options.loop && this.currentIndex === this.maxIndex - 1);
101 }
102 clearCarouselStyles() {
103 ["grid-auto-columns", "gap", "transition", "left"].map((t) => this.track.style.removeProperty(t));
104 const t = ["grid-column-start", "grid-column-end", "grid-row-start", "grid-row-end", "left"];
105 this.slides.forEach((i) => {
106 t.map((t) => i.style.removeProperty(t));
107 });
108 }
109 setCarouselStyles() {
110 if (!this.slides) return;
111 const t = this.options.slidesPerView,
112 i = 100 / t,
113 e = (this.options.spacing * (t - 1)) / t;
114 (this.track.style.gridAutoColumns = `calc(${i}% - ${e}px)`), (this.track.style.gridGap = `${this.options.spacing}px`), (this.track.style.left = 0);
115 }
116 buildCarousel() {
117 (this.maxIndex = Math.ceil(this.slidesLength / this.options.slidesPerView)), this.clearCarouselStyles(), this.setCarouselStyles(), this.setButtonsVisibility(), this.setUpAutoplay(), (this.currentIndex = 0), this.hook("built");
118 }
119 initCarousel() {
120 (this.slides = this.container.querySelectorAll(this.slidesSelector)), (this.slidesLength = this.slides?.length), this.checkBreakpoint(), this.buildCarousel(), this.hook("created");
121 }
122 onAnimationEnd() {
123 const t = this.options.spacing * this.animationIndex,
124 i = -100 * this.animationIndex;
125 (this.track.style.left = `calc(${i}% - ${t}px)`), (this.animationCurrentTrans = i), (this.animation = null), this.isInfinite && this.clearInfinite(), this.isPrevInfinite && this.clearPrevInfinite();
126 }
127 moveAnimateAbort() {
128 this.animation && (window.cancelAnimationFrame(this.animation), this.onAnimationEnd());
129 }
130 animateLeft(t, i, e, s) {
131 const n = t - this.animationStart,
132 o = ((r = n / s), 1 - Math.pow(1 - r, 5));
133 var r;
134 const a = (i * o + this.animationCurrentTrans * (1 - o)).toFixed(2);
135 (this.track.style.left = `calc(${a}% - ${e}px)`),
136 n >= s
137 ? this.onAnimationEnd()
138 : (this.animation = window.requestAnimationFrame((t) => {
139 this.animateLeft(t, i, e, s);
140 }));
141 }
142 moveSlide(t, i) {
143 this.moveAnimateAbort();
144 const e = this.options.spacing * t,
145 s = -100 * t;
146 (this.animation = window.requestAnimationFrame((i) => {
147 t === this.maxIndex && this.setInfinite(), -1 === t && this.setPrevInfinite(), (this.animationStart = i), (this.animationIndex = this.currentIndex), this.animateLeft(i, s, e, this.options.transitionSpeed);
148 })),
149 (this.currentIndex = i),
150 this.setUpAutoplay(),
151 this.setButtonsVisibility(),
152 this.hook("moved");
153 }
154 setInfinite() {
155 this.isInfinite = !0;
156 const t = this.options.slidesPerView * this.maxIndex;
157 for (let i = 0; i < this.options.slidesPerView; i++) {
158 this.slides[i].style.left = `calc((100% * ${t}) + (${this.options.spacing}px * ${t}))`;
159 }
160 }
161 clearInfinite() {
162 (this.isInfinite = !1),
163 (this.track.style.left = `calc(${-100 * this.currentIndex}% - ${this.options.spacing * this.currentIndex}px)`),
164 this.slides.forEach((t, i) => {
165 i >= this.options.slidesPerView || t.style.removeProperty("left");
166 });
167 }
168 next() {
169 const t = this.currentIndex === this.maxIndex - 1 ? 0 : this.currentIndex + 1;
170 (!this.options.loop && t < this.currentIndex) || (t < this.currentIndex ? this.moveSlide(this.currentIndex + 1, t) : this.moveSlide(t, t));
171 }
172 setPrevInfinite() {
173 this.isPrevInfinite = !0;
174 const t = this.options.slidesPerView * this.maxIndex,
175 i = t - this.options.slidesPerView;
176 for (let e = this.slides.length - 1; e >= 0; e--) {
177 if (e < i) return;
178 this.slides[e].style.left = `calc((-100% * ${t}) - (${this.options.spacing}px * ${t}))`;
179 }
180 }
181 clearPrevInfinite() {
182 (this.isPrevInfinite = !1),
183 (this.track.style.left = `calc(${-100 * this.currentIndex}% - ${this.options.spacing * this.currentIndex}px)`),
184 this.slides.forEach((t, i) => {
185 t.style.removeProperty("left");
186 });
187 }
188 prev() {
189 const t = 0 === this.currentIndex ? this.maxIndex - 1 : this.currentIndex - 1;
190 (!this.options.loop && t > this.currentIndex) || (t > this.currentIndex ? this.moveSlide(this.currentIndex - 1, t) : this.moveSlide(t, t));
191 }
192 moveToSlide(t) {
193 t !== this.currentIndex && this.moveSlide(t, t);
194 }
195 getSlides() {
196 return this.slides;
197 }
198 getCurrentIndex() {
199 return this.currentIndex;
200 }
201 getOptions() {
202 return this.options;
203 }
204 getPageSize() {
205 return this.maxIndex;
206 }
207 };
208