@preline/carousel 2.3.0 → 2.4.0
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/LICENSE +31 -1
- package/index.d.ts +3 -2
- package/index.js +11 -11
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
@Author: Preline Labs Ltd.
|
|
2
|
+
@Website: https://preline.co
|
|
3
|
+
@License: Preline UI is free for both personal and commercial projects, released under dual license terms "MIT" and "Preline UI Fair Use License", and copyrighted 2024 by Preline Labs Ltd.
|
|
4
|
+
|
|
1
5
|
MIT License
|
|
2
6
|
|
|
3
|
-
Copyright (c)
|
|
7
|
+
Copyright (c) 2024 Preline Labs Ltd.
|
|
4
8
|
|
|
5
9
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
10
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -19,3 +23,29 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
23
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
24
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
25
|
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
Preline UI Fair Use License
|
|
29
|
+
|
|
30
|
+
1. Usage Restrictions:
|
|
31
|
+
- Competing Products: The Software shall not be used to create any product or service that directly competes with Preline UI. A competing product is defined as any software or service that replicates the primary functionalities of Preline UI.
|
|
32
|
+
- Misuse and Abuse: The Software shall not be used for any activities that are deemed harmful, abusive, or intended to deceive end-users. This includes, but is not limited to, creating malware, engaging in fraudulent activities, or infringing on the rights of others.
|
|
33
|
+
|
|
34
|
+
2. Commercial Derivative Works:
|
|
35
|
+
Users are permitted to create and sell derivative works such as templates, themes, and page builders, provided that:
|
|
36
|
+
- The derivative works must not be marketed as competing products.
|
|
37
|
+
- Proper attribution must be given to the original author, including the name "Preline UI" and a link to the original repository.
|
|
38
|
+
- A clear distinction must be made between the original work and the derivative work, ensuring that users understand the source of each.
|
|
39
|
+
|
|
40
|
+
3. Distribution and Sublicensing:
|
|
41
|
+
Redistribution of the Software in its original or modified form is allowed under the MIT License, with the following additional conditions:
|
|
42
|
+
- Redistributions must include this Fair Use License in addition to the MIT License.
|
|
43
|
+
- Redistributions must not remove or alter any licensing information or notices.
|
|
44
|
+
- Must include clear attribution with a link to the original repository.
|
|
45
|
+
|
|
46
|
+
4. Termination:
|
|
47
|
+
The author reserves the right to terminate the rights granted under this Fair Use License if the user fails to comply with the terms. Upon termination, the user must cease all use and distribution of the Software, and destroy all copies in their possession.
|
|
48
|
+
|
|
49
|
+
5. Enforcement and Compliance:
|
|
50
|
+
- Users who believe that the terms of this Fair Use License have been violated are encouraged to report the violation to the author.
|
|
51
|
+
- The author reserves the right to take legal action to enforce compliance with this Fair Use License.
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
export interface IBasePlugin<O, E> {
|
|
4
2
|
el: E;
|
|
5
3
|
options?: O;
|
|
@@ -24,6 +22,7 @@ export interface ICarouselOptions {
|
|
|
24
22
|
isAutoPlay?: boolean;
|
|
25
23
|
speed?: number;
|
|
26
24
|
isInfiniteLoop?: boolean;
|
|
25
|
+
isRTL?: boolean;
|
|
27
26
|
}
|
|
28
27
|
export interface ICarousel {
|
|
29
28
|
options?: ICarouselOptions;
|
|
@@ -45,6 +44,7 @@ declare class HSCarousel extends HSBasePlugin<ICarouselOptions> implements ICaro
|
|
|
45
44
|
private readonly loadingClassesAdd;
|
|
46
45
|
private readonly afterLoadingClassesAdd;
|
|
47
46
|
private readonly isAutoPlay;
|
|
47
|
+
private readonly isRTL;
|
|
48
48
|
private readonly speed;
|
|
49
49
|
private readonly isInfiniteLoop;
|
|
50
50
|
private timer;
|
|
@@ -60,6 +60,7 @@ declare class HSCarousel extends HSBasePlugin<ICarouselOptions> implements ICaro
|
|
|
60
60
|
private resetTimer;
|
|
61
61
|
private detectDirection;
|
|
62
62
|
recalculateWidth(): void;
|
|
63
|
+
private calculateTransform;
|
|
63
64
|
goToPrev(): void;
|
|
64
65
|
goToNext(): void;
|
|
65
66
|
goTo(i: number): void;
|
package/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var s=e();for(var i in s)("object"==typeof exports?exports:t)[i]=s[i]}}(self,(()=>(()=>{"use strict";var t={
|
|
1
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var s=e();for(var i in s)("object"==typeof exports?exports:t)[i]=s[i]}}(self,(()=>(()=>{"use strict";var t={961:(t,e)=>{
|
|
2
2
|
/*
|
|
3
3
|
* HSBasePlugin
|
|
4
|
-
* @version: 2.
|
|
5
|
-
* @author:
|
|
6
|
-
* @license: Licensed under MIT (https://preline.co/docs/license.html)
|
|
7
|
-
* Copyright
|
|
4
|
+
* @version: 2.4.0
|
|
5
|
+
* @author: Preline Labs Ltd.
|
|
6
|
+
* @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
|
|
7
|
+
* Copyright 2024 Preline Labs Ltd.
|
|
8
8
|
*/
|
|
9
|
-
Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e,s){this.el=t,this.options=e,this.events=s,this.el=t,this.options=e,this.events={}}return t.prototype.createCollection=function(t,e){var s;t.push({id:(null===(s=null==e?void 0:e.el)||void 0===s?void 0:s.id)||t.length+1,element:e})},t.prototype.fireEvent=function(t,e){if(void 0===e&&(e=null),this.events.hasOwnProperty(t))return this.events[t](e)},t.prototype.on=function(t,e){this.events[t]=e},t}();e.default=s},
|
|
9
|
+
Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e,s){this.el=t,this.options=e,this.events=s,this.el=t,this.options=e,this.events={}}return t.prototype.createCollection=function(t,e){var s;t.push({id:(null===(s=null==e?void 0:e.el)||void 0===s?void 0:s.id)||t.length+1,element:e})},t.prototype.fireEvent=function(t,e){if(void 0===e&&(e=null),this.events.hasOwnProperty(t))return this.events[t](e)},t.prototype.on=function(t,e){this.events[t]=e},t}();e.default=s},268:function(t,e,s){
|
|
10
10
|
/*
|
|
11
11
|
* HSCarousel
|
|
12
|
-
* @version: 2.
|
|
13
|
-
* @author:
|
|
14
|
-
* @license: Licensed under MIT (https://preline.co/docs/license.html)
|
|
15
|
-
* Copyright
|
|
12
|
+
* @version: 2.4.0
|
|
13
|
+
* @author: Preline Labs Ltd.
|
|
14
|
+
* @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
|
|
15
|
+
* Copyright 2024 Preline Labs Ltd.
|
|
16
16
|
*/
|
|
17
|
-
var i,n=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function s(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(s.prototype=e.prototype,new s)}),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,s=1,i=arguments.length;s<i;s++)for(var n in e=arguments[s])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},o.apply(this,arguments)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var l=function(t){function e(e,s){var i,n,r,l=t.call(this,e,s)||this,a=e.getAttribute("data-hs-carousel"),d=a?JSON.parse(a):{},c=o(o({},d),s);return l.currentIndex=c.currentIndex||0,l.loadingClasses=c.loadingClasses?"".concat(c.loadingClasses).split(","):null,l.loadingClassesRemove=(null===(i=l.loadingClasses)||void 0===i?void 0:i[0])?l.loadingClasses[0].split(" "):"opacity-0",l.loadingClassesAdd=(null===(n=l.loadingClasses)||void 0===n?void 0:n[1])?l.loadingClasses[1].split(" "):"",l.afterLoadingClassesAdd=(null===(r=l.loadingClasses)||void 0===r?void 0:r[2])?l.loadingClasses[2].split(" "):"",l.isAutoPlay=void 0!==c.isAutoPlay&&c.isAutoPlay,l.speed=c.speed||4e3,l.isInfiniteLoop=void 0===c.isInfiniteLoop||c.isInfiniteLoop,l.inner=l.el.querySelector(".hs-carousel-body")||null,l.slides=l.el.querySelectorAll(".hs-carousel-slide")||[],l.prev=l.el.querySelector(".hs-carousel-prev")||null,l.next=l.el.querySelector(".hs-carousel-next")||null,l.dots=l.el.querySelectorAll(".hs-carousel-pagination > *")||null,l.sliderWidth=l.inner.parentElement.clientWidth,l.touchX={start:0,end:0},l.init(),l}return n(e,t),e.prototype.init=function(){var t,e,s=this;this.createCollection(window.$hsCarouselCollection,this),this.inner&&(this.calculateWidth(),this.loadingClassesRemove&&("string"==typeof this.loadingClassesRemove?this.inner.classList.remove(this.loadingClassesRemove):(t=this.inner.classList).remove.apply(t,this.loadingClassesRemove)),this.loadingClassesAdd&&("string"==typeof this.loadingClassesAdd?this.inner.classList.add(this.loadingClassesAdd):(e=this.inner.classList).add.apply(e,this.loadingClassesAdd))),this.prev&&this.prev.addEventListener("click",(function(){s.goToPrev(),s.isAutoPlay&&(s.resetTimer(),s.setTimer())})),this.next&&this.next.addEventListener("click",(function(){s.goToNext(),s.isAutoPlay&&(s.resetTimer(),s.setTimer())})),this.dots&&this.dots.forEach((function(t,e){return t.addEventListener("click",(function(){s.goTo(e),s.isAutoPlay&&(s.resetTimer(),s.setTimer())}))})),this.slides.length&&(this.addCurrentClass(),this.isInfiniteLoop||this.addDisabledClass(),this.isAutoPlay&&this.autoPlay()),this.inner&&this.afterLoadingClassesAdd&&setTimeout((function(){var t;"string"==typeof s.afterLoadingClassesAdd?s.inner.classList.add(s.afterLoadingClassesAdd):(t=s.inner.classList).add.apply(t,s.afterLoadingClassesAdd)})),this.el.classList.add("init"),this.el.addEventListener("touchstart",(function(t){s.touchX.start=t.changedTouches[0].screenX})),this.el.addEventListener("touchend",(function(t){s.touchX.end=t.changedTouches[0].screenX,s.detectDirection()})),this.observeResize()},e.prototype.observeResize=function(){var t=this;new ResizeObserver((function(){return t.recalculateWidth()})).observe(document.querySelector("body"))},e.prototype.calculateWidth=function(){var t=this;this.inner.style.width="".concat(this.sliderWidth*this.slides.length,"px"),this.inner.style.transform=
|
|
17
|
+
var i,n=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function s(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(s.prototype=e.prototype,new s)}),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,s=1,i=arguments.length;s<i;s++)for(var n in e=arguments[s])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},o.apply(this,arguments)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var l=function(t){function e(e,s){var i,n,r,l=t.call(this,e,s)||this,a=e.getAttribute("data-hs-carousel"),d=a?JSON.parse(a):{},c=o(o({},d),s);return l.currentIndex=c.currentIndex||0,l.loadingClasses=c.loadingClasses?"".concat(c.loadingClasses).split(","):null,l.loadingClassesRemove=(null===(i=l.loadingClasses)||void 0===i?void 0:i[0])?l.loadingClasses[0].split(" "):"opacity-0",l.loadingClassesAdd=(null===(n=l.loadingClasses)||void 0===n?void 0:n[1])?l.loadingClasses[1].split(" "):"",l.afterLoadingClassesAdd=(null===(r=l.loadingClasses)||void 0===r?void 0:r[2])?l.loadingClasses[2].split(" "):"",l.isAutoPlay=void 0!==c.isAutoPlay&&c.isAutoPlay,l.speed=c.speed||4e3,l.isInfiniteLoop=void 0===c.isInfiniteLoop||c.isInfiniteLoop,l.isRTL=void 0!==c.isRTL&&c.isRTL,l.inner=l.el.querySelector(".hs-carousel-body")||null,l.slides=l.el.querySelectorAll(".hs-carousel-slide")||[],l.prev=l.el.querySelector(".hs-carousel-prev")||null,l.next=l.el.querySelector(".hs-carousel-next")||null,l.dots=l.el.querySelectorAll(".hs-carousel-pagination > *")||null,l.sliderWidth=l.inner.parentElement.clientWidth,l.touchX={start:0,end:0},l.init(),l}return n(e,t),e.prototype.init=function(){var t,e,s=this;this.createCollection(window.$hsCarouselCollection,this),this.inner&&(this.calculateWidth(),this.loadingClassesRemove&&("string"==typeof this.loadingClassesRemove?this.inner.classList.remove(this.loadingClassesRemove):(t=this.inner.classList).remove.apply(t,this.loadingClassesRemove)),this.loadingClassesAdd&&("string"==typeof this.loadingClassesAdd?this.inner.classList.add(this.loadingClassesAdd):(e=this.inner.classList).add.apply(e,this.loadingClassesAdd))),this.prev&&this.prev.addEventListener("click",(function(){s.goToPrev(),s.isAutoPlay&&(s.resetTimer(),s.setTimer())})),this.next&&this.next.addEventListener("click",(function(){s.goToNext(),s.isAutoPlay&&(s.resetTimer(),s.setTimer())})),this.dots&&this.dots.forEach((function(t,e){return t.addEventListener("click",(function(){s.goTo(e),s.isAutoPlay&&(s.resetTimer(),s.setTimer())}))})),this.slides.length&&(this.addCurrentClass(),this.isInfiniteLoop||this.addDisabledClass(),this.isAutoPlay&&this.autoPlay()),this.inner&&this.afterLoadingClassesAdd&&setTimeout((function(){var t;"string"==typeof s.afterLoadingClassesAdd?s.inner.classList.add(s.afterLoadingClassesAdd):(t=s.inner.classList).add.apply(t,s.afterLoadingClassesAdd)})),this.el.classList.add("init"),this.el.addEventListener("touchstart",(function(t){s.touchX.start=t.changedTouches[0].screenX})),this.el.addEventListener("touchend",(function(t){s.touchX.end=t.changedTouches[0].screenX,s.detectDirection()})),this.observeResize()},e.prototype.observeResize=function(){var t=this;new ResizeObserver((function(){return t.recalculateWidth()})).observe(document.querySelector("body"))},e.prototype.calculateWidth=function(){var t=this;this.inner.style.width="".concat(this.sliderWidth*this.slides.length,"px"),this.inner.style.transform=this.calculateTransform(),this.slides.forEach((function(e){e.style.width="".concat(t.sliderWidth,"px")}))},e.prototype.addCurrentClass=function(){var t=this;this.slides.forEach((function(e,s){s===t.currentIndex?e.classList.add("active"):e.classList.remove("active")})),this.dots&&this.dots.forEach((function(e,s){s===t.currentIndex?e.classList.add("active"):e.classList.remove("active")}))},e.prototype.addDisabledClass=function(){if(!this.prev||!this.next)return!1;0===this.currentIndex?(this.next.classList.remove("disabled"),this.prev.classList.add("disabled")):this.currentIndex===this.slides.length-1?(this.prev.classList.remove("disabled"),this.next.classList.add("disabled")):(this.prev.classList.remove("disabled"),this.next.classList.remove("disabled"))},e.prototype.autoPlay=function(){this.setTimer()},e.prototype.setTimer=function(){var t=this;this.timer=setInterval((function(){t.currentIndex===t.slides.length-1?t.goTo(0):t.goToNext()}),this.speed)},e.prototype.resetTimer=function(){clearInterval(this.timer)},e.prototype.detectDirection=function(){var t=this.touchX,e=t.start,s=t.end;s<e&&this.goToNext(),s>e&&this.goToPrev()},e.prototype.recalculateWidth=function(){this.sliderWidth=this.inner.parentElement.clientWidth,this.calculateWidth()},e.prototype.calculateTransform=function(){var t=this.currentIndex*this.sliderWidth;return this.isRTL?"translate(".concat(t,"px, 0px)"):"translate(-".concat(t,"px, 0px)")},e.prototype.goToPrev=function(){0===this.currentIndex&&this.isInfiniteLoop?(this.currentIndex=this.slides.length-1,this.inner.style.transform=this.calculateTransform(),this.addCurrentClass()):0!==this.currentIndex&&(this.currentIndex-=1,this.inner.style.transform=this.calculateTransform(),this.addCurrentClass(),this.addDisabledClass())},e.prototype.goToNext=function(){this.currentIndex===this.slides.length-1&&this.isInfiniteLoop?(this.currentIndex=0,this.inner.style.transform=this.calculateTransform(),this.addCurrentClass()):this.currentIndex<this.slides.length-1&&(this.currentIndex+=1,this.inner.style.transform=this.calculateTransform(),this.addCurrentClass(),this.addDisabledClass())},e.prototype.goTo=function(t){this.currentIndex=t,this.inner.style.transform=this.calculateTransform(),this.addCurrentClass(),this.isInfiniteLoop||this.addDisabledClass()},e.getInstance=function(t,e){var s=window.$hsCarouselCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));return s?e?s:s.element:null},e.autoInit=function(){window.$hsCarouselCollection||(window.$hsCarouselCollection=[]),document.querySelectorAll("[data-hs-carousel]:not(.--prevent-on-load-init)").forEach((function(t){window.$hsCarouselCollection.find((function(e){var s;return(null===(s=null==e?void 0:e.element)||void 0===s?void 0:s.el)===t}))||new e(t)}))},e}(r(s(961)).default);window.addEventListener("load",(function(){l.autoInit()})),window.addEventListener("resize",(function(){if(!window.$hsCarouselCollection)return!1;window.$hsCarouselCollection.forEach((function(t){t.element.recalculateWidth()}))})),"undefined"!=typeof window&&(window.HSCarousel=l),e.default=l}},e={};var s=function s(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,s),o.exports}(268);return s})()));
|
package/package.json
CHANGED