versoly-marquee 1.0.1
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.md +21 -0
- package/README.md +89 -0
- package/dist/index.cjs +1 -0
- package/dist/index.global.min.js +1 -0
- package/dist/index.mjs +30 -0
- package/package.json +46 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Versoly Marquee (Versoly Limited) <volkan@versoly.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<div align="">
|
|
2
|
+
<h1>Versoly Marquee</h1>
|
|
3
|
+
<p>A simple and small JS library to create marquee animations</p>
|
|
4
|
+
<ul>
|
|
5
|
+
<li>800 bytes</li>
|
|
6
|
+
<li>Stop animation on hover</li>
|
|
7
|
+
<li>Speed control</li>
|
|
8
|
+
</ul>
|
|
9
|
+
<p>
|
|
10
|
+
<a href="https://discord.versoly.com"><img src="https://flat.badgen.net/badge/icon/discord?icon=discord&label" alt="Discord"></a>
|
|
11
|
+
<a href="https://github.com/versoly/versoly-marquee/tree/main?tab=MIT-1-ov-file"><img src="https://img.shields.io/badge/license-MIT-blue" alt="Licenese"></a>
|
|
12
|
+
<a href="https://bundlephobia.com/result?p=versoly-marquee">
|
|
13
|
+
<img src="https://flat.badgen.net/bundlephobia/minzip/versoly-marquee?icon=packagephobia&label&color=blue&cache=10800" alt="gzip bundle size">
|
|
14
|
+
</a>
|
|
15
|
+
</p>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
------
|
|
19
|
+
|
|
20
|
+
[](https://versoly.com/tailwind-page-builder?utm_source=github&utm_medium=repo&utm_campaign=image&utm_term=versoly-marquee)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Getting started
|
|
24
|
+
|
|
25
|
+
Versoly marquee can be installed using npm, pnpm, CDNs. It is also tiny so you could just copy paste it onto a landing page for improved page speed.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Install versoly-marquee package
|
|
29
|
+
```js
|
|
30
|
+
npm install versoly-marquee --save
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### import versoly-marquee package
|
|
34
|
+
```js
|
|
35
|
+
import { Marquee } from "versoly-marquee";
|
|
36
|
+
|
|
37
|
+
// add data-toggle="marquee"
|
|
38
|
+
document.querySelectorAll('[data-toggle="marquee"]').forEach((elem) => {
|
|
39
|
+
// set options on the element using data-options="{'duration': 10, 'direction': 'rtl'}"
|
|
40
|
+
let t = elem.dataset.options || "{}";
|
|
41
|
+
// parse data-options using replace for security instead of eval
|
|
42
|
+
let options = JSON.parse(t.replaceAll("'", '"'));
|
|
43
|
+
// add Marquee animation
|
|
44
|
+
const marquee = new Marquee(elem, options);
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### CDN
|
|
50
|
+
```html
|
|
51
|
+
<script src="https://unpkg.com/versoly-marquee@1/dist/index.global.min.js"></script>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## Frequently Asked Questions
|
|
56
|
+
|
|
57
|
+
### Why create Versoly Marquee
|
|
58
|
+
|
|
59
|
+
It shouldn't require custom JS and re-inventing the wheel every time to add the same features to landing pages and marketing sites.
|
|
60
|
+
|
|
61
|
+
By default if you want a marquee you should use versoly-marquee, and only if it doesn't fit your use case to build it yourself.
|
|
62
|
+
|
|
63
|
+
### Why not just use CSS?
|
|
64
|
+
|
|
65
|
+
Versoly Marquee was built to be used in Versoly page builder + CMS and other headless CMSs, this means that non-technical users would be changing content that would effect the CSS required to make it work.
|
|
66
|
+
|
|
67
|
+
There is no way to only use CSS to create a marquee that isn't a fixed width.
|
|
68
|
+
|
|
69
|
+
### Why not use a slider library?
|
|
70
|
+
|
|
71
|
+
Slider libraries are usually 20-100x bigger than versoly-marquee, 99% of the features aren't needed.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## Roadmap
|
|
75
|
+
|
|
76
|
+
- Responsive options
|
|
77
|
+
- Plugins. On scroll, on mouse over.
|
|
78
|
+
- Vue/React and other JS frameworks
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
## Community
|
|
82
|
+
|
|
83
|
+
If you need help or just want to discuss about the library join the community on Github:
|
|
84
|
+
|
|
85
|
+
[Discuss on GitHub](https://github.com/versoly/versoly-marquee/discussions)
|
|
86
|
+
|
|
87
|
+
For casual chatting with others using the library:
|
|
88
|
+
|
|
89
|
+
[Join the Versoly Discord Server](https://discord.versoly.com)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=function(a,r={}){var S,w,N;let T=(S=r.loop)!=null?S:!0,x=r.duration||5,i=r.direction||"ltr",H=(w=r.pauseable)!=null?w:!0,m=(N=r.iterations)!=null?N:1,o=0,e=null,t=null,v=this,c=0,M=0,l=0,u=0,f=!1,b=null;const s=i.includes("tt"),q=s?"Y":"X",d=s?"height":"width",z="offset"+(s?"Height":"Width");let p=10/(x*1e3);const E=function(n){const g=n.innerHTML,C=n.childNodes[1]||n;if(u=n[z],t=C[z],t===0)return;const y=Math.ceil((u+1)/t)+3;if(e="<div>"+g+"</div>",n.innerHTML=e,e=n.getElementsByTagName("div")[0],n.style.overflow="clip",e.style[d]=t*y+"px",e.style.whiteSpace="nowrap",e.style.position="relative",e.style.display="flex",e.style.flexDirection=s?"column":"row",m){for(let h=0;h<y-1;h++)e.innerHTML+=g,e.children[h].style["min-"+d]=t+"px";e.style[d]=y*t,(i==="ltr"||i==="ttb")&&(l=-t)}else c=u,(i==="rtl"||i==="btt")&&(o=c);return i==="ltr"||i==="ttb"?o=-t:(i==="rtl"||i==="btt")&&(p=-p),v.init(),e};this.init=function(){b=setInterval(v.play,10),H&&(a.addEventListener("mouseenter",()=>f=!0),a.addEventListener("mouseleave",()=>f=!1))},this.play=function(){f||(e.style.transform="translate".concat(q,"(").concat(l,"px)"),l+=p*t,(l>c||l<-t)&&(l=o,M++,T!==!0&&M>=m&&(e.style.transform="")))},this.end=function(){clearInterval(b)},E(a)};window.Marquee=L;exports.Marquee=L;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Marquee=function(a){"use strict";const v=function(o,l={}){var N,g,L;let q=(N=l.loop)!=null?N:!0,H=l.duration||5,i=l.direction||"ltr",E=(g=l.pauseable)!=null?g:!0,M=(L=l.iterations)!=null?L:1,c=0,e=null,t=null,b=this,u=0,z=0,r=0,f=0,d=!1,S=null;const s=i.includes("tt"),x=s?"Y":"X",y=s?"height":"width",w="offset"+(s?"Height":"Width");let p=10/(H*1e3);const C=function(n){const T=n.innerHTML,I=n.childNodes[1]||n;if(f=n[w],t=I[w],t===0)return;const h=Math.ceil((f+1)/t)+3;if(e="<div>"+T+"</div>",n.innerHTML=e,e=n.getElementsByTagName("div")[0],n.style.overflow="clip",e.style[y]=t*h+"px",e.style.whiteSpace="nowrap",e.style.position="relative",e.style.display="flex",e.style.flexDirection=s?"column":"row",M){for(let m=0;m<h-1;m++)e.innerHTML+=T,e.children[m].style["min-"+y]=t+"px";e.style[y]=h*t,(i==="ltr"||i==="ttb")&&(r=-t)}else u=f,(i==="rtl"||i==="btt")&&(c=u);return i==="ltr"||i==="ttb"?c=-t:(i==="rtl"||i==="btt")&&(p=-p),b.init(),e};this.init=function(){S=setInterval(b.play,10),E&&(o.addEventListener("mouseenter",()=>d=!0),o.addEventListener("mouseleave",()=>d=!1))},this.play=function(){d||(e.style.transform="translate".concat(x,"(").concat(r,"px)"),r+=p*t,(r>u||r<-t)&&(r=c,z++,q!==!0&&z>=M&&(e.style.transform="")))},this.end=function(){clearInterval(S)},C(o)};return window.Marquee=v,a.Marquee=v,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),a}({});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const C = function(a, r = {}) {
|
|
2
|
+
var N, b, x;
|
|
3
|
+
let S = (N = r.loop) != null ? N : !0, H = r.duration || 5, i = r.direction || "ltr", T = (b = r.pauseable) != null ? b : !0, m = (x = r.iterations) != null ? x : 1, o = 0, t = null, e = null, v = this, c = 0, z = 0, l = 0, f = 0, u = !1, w = null;
|
|
4
|
+
const s = i.includes("tt"), g = s ? "Y" : "X", d = s ? "height" : "width", M = "offset" + (s ? "Height" : "Width");
|
|
5
|
+
let p = 10 / (H * 1e3);
|
|
6
|
+
const E = function(n) {
|
|
7
|
+
const L = n.innerHTML, q = n.childNodes[1] || n;
|
|
8
|
+
if (f = n[M], e = q[M], e === 0)
|
|
9
|
+
return;
|
|
10
|
+
const y = Math.ceil((f + 1) / e) + 3;
|
|
11
|
+
if (t = "<div>" + L + "</div>", n.innerHTML = t, t = n.getElementsByTagName("div")[0], n.style.overflow = "clip", t.style[d] = e * y + "px", t.style.whiteSpace = "nowrap", t.style.position = "relative", t.style.display = "flex", t.style.flexDirection = s ? "column" : "row", m) {
|
|
12
|
+
for (let h = 0; h < y - 1; h++)
|
|
13
|
+
t.innerHTML += L, t.children[h].style["min-" + d] = e + "px";
|
|
14
|
+
t.style[d] = y * e, (i === "ltr" || i === "ttb") && (l = -e);
|
|
15
|
+
} else
|
|
16
|
+
c = f, (i === "rtl" || i === "btt") && (o = c);
|
|
17
|
+
return i === "ltr" || i === "ttb" ? o = -e : (i === "rtl" || i === "btt") && (p = -p), v.init(), t;
|
|
18
|
+
};
|
|
19
|
+
this.init = function() {
|
|
20
|
+
w = setInterval(v.play, 10), T && (a.addEventListener("mouseenter", () => u = !0), a.addEventListener("mouseleave", () => u = !1));
|
|
21
|
+
}, this.play = function() {
|
|
22
|
+
u || (t.style.transform = "translate".concat(g, "(").concat(l, "px)"), l += p * e, (l > c || l < -e) && (l = o, z++, S !== !0 && z >= m && (t.style.transform = "")));
|
|
23
|
+
}, this.end = function() {
|
|
24
|
+
clearInterval(w);
|
|
25
|
+
}, E(a);
|
|
26
|
+
};
|
|
27
|
+
window.Marquee = C;
|
|
28
|
+
export {
|
|
29
|
+
C as Marquee
|
|
30
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "versoly-marquee",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Marquee - A simple and small JS library to create marquee animations",
|
|
5
|
+
"author": "Versoly",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"marquee",
|
|
9
|
+
"Versoly Marquee",
|
|
10
|
+
"marquee CSS",
|
|
11
|
+
"marquee JS",
|
|
12
|
+
"versoly"
|
|
13
|
+
],
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "dist/versoly-marquee.cjs",
|
|
19
|
+
"unpkg": "dist/versoly-marquee.global.min.js",
|
|
20
|
+
"jsdelivr": "dist/versoly-marquee.global.min.js",
|
|
21
|
+
"module": "./dist/versoly-marquee.mjs",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./dist/versoly-marquee.mjs",
|
|
25
|
+
"require": "./dist/versoly-marquee.cjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/versoly/versoly-marquee.git"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/versoly/versoly-marquee/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://versoly.com/versoly-marquee",
|
|
36
|
+
"contributors": [
|
|
37
|
+
"Volkan Kaya <volkan@versoly.com>"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"dev": "vite",
|
|
41
|
+
"build": "vite build"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"vite": "^5.4.11"
|
|
45
|
+
}
|
|
46
|
+
}
|