marquee-content 0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 ux-ui.pro
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,38 @@
1
+ <div align="center">
2
+ <br>
3
+
4
+ <h1>marquee-content</h1>
5
+
6
+ [![npm](https://img.shields.io/npm/v/marquee-content.svg?colorB=brightgreen)](https://www.npmjs.com/package/marquee-content)
7
+ [![GitHub package version](https://img.shields.io/github/package-json/v/ux-ui-pro/marquee-content.svg)](https://github.com/ux-ui-pro/marquee-content)
8
+ [![NPM Downloads](https://img.shields.io/npm/dm/marquee-content.svg?style=flat)](https://www.npmjs.org/package/marquee-content)
9
+
10
+ <p>Marquee content with GSAP</p>
11
+
12
+ <p>
13
+ <a href="https://ux-ui-pro.github.io/marquee-content/dist/">Demo</a>
14
+ <br>
15
+ <a href="https://github.com/ux-ui-pro/marquee-content/releases/latest">Download</a>
16
+ </p>
17
+
18
+ </div>
19
+ <br>
20
+
21
+ ### Installation
22
+ ```javascript
23
+ $ yarn add marquee-content
24
+ ```
25
+ <sup>or</sup>
26
+ ```javascript
27
+ $ npm i marquee-content
28
+ ```
29
+ <br>
30
+
31
+ ### Import
32
+ ```javascript
33
+ import { MarqueeContent } from 'marquee-content'
34
+ ```
35
+ <br>
36
+
37
+ ### License
38
+ marquee-content is released under MIT license
@@ -0,0 +1,101 @@
1
+ <!DOCTYPE html>
2
+ <html lang="ru">
3
+ <head>
4
+ <title>marquee-content</title>
5
+ <meta name="robots" content="none">
6
+ <meta charset="UTF-8">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
8
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
9
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css">
10
+ <style type="text/css">
11
+ html {
12
+ font-family: system-ui, -apple-system, "Open Sans", "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
13
+ font-size: 10px;
14
+ }
15
+
16
+ body {
17
+ margin: 0;
18
+ font-feature-settings: "kern" 1,"liga" 0;
19
+ font-size: 1.6rem;
20
+ font-weight: 400;
21
+ line-height: 1.5;
22
+ }
23
+
24
+ html,
25
+ body,
26
+ input,
27
+ textarea,
28
+ button {
29
+ -webkit-font-smoothing: subpixel-antialiased;
30
+ }
31
+
32
+ .layout {
33
+ max-width: 120rem;
34
+ margin: 0 auto;
35
+ border: 1px solid red;
36
+ border-top: none;
37
+ border-bottom: none;
38
+ }
39
+
40
+ ul {
41
+ display: flex;
42
+ list-style: none;
43
+ margin: 0; padding: 0;
44
+ }
45
+
46
+ li {
47
+ width: 200px;
48
+ margin: 0 20px;
49
+ background: lightgray;
50
+ text-align: center;
51
+ }
52
+
53
+ marquee-content {
54
+ pointer-events: none;
55
+ max-width: 100vw;
56
+ justify-content: center;
57
+ align-items: center;
58
+ display: flex;
59
+ position: relative;
60
+ overflow: hidden;
61
+ }
62
+ </style>
63
+ </head>
64
+ <body>
65
+ <div class="layout">
66
+ <marquee-content
67
+ data-mc-min="1600"
68
+ data-mc-clone="2"
69
+ data-mc-speed="30"
70
+ data-mc-skew="-2.4"
71
+ role="marquee">
72
+ <ul class="logo-set">
73
+ <li class="logo-set__item">
74
+ 1
75
+ </li>
76
+ <li class="logo-set__item">
77
+ 2
78
+ </li>
79
+ <li class="logo-set__item">
80
+ 3
81
+ </li>
82
+ <li class="logo-set__item">
83
+ 4
84
+ </li>
85
+ <li class="logo-set__item">
86
+ 5
87
+ </li>
88
+ <li class="logo-set__item">
89
+ 6
90
+ </li>
91
+ <li class="logo-set__item">
92
+ 7
93
+ </li>
94
+ </ul>
95
+ </marquee-content>
96
+ </div>
97
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.5/gsap.min.js"></script>
98
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.5/ScrollTrigger.min.js"></script>
99
+ <script src="js/marquee-content.min.js"></script>
100
+ </body>
101
+ </html>
@@ -0,0 +1 @@
1
+ (()=>{"use strict";class t extends HTMLElement{constructor(){super(),this.speed=this.dataset.mcSpeed||20,this.clone=this.dataset.mcClone,this.skew=this.dataset.mcSkew,this.abs=this.skew<0?-1*this.skew:this.skew,this.max=this.dataset.mcMax,this.min=this.dataset.mcMin,this.mm=gsap.matchMedia(),this.breakpoints(),this.cloning(),this.skewed(),this.animate()}breakpoints(){this.max||this.min?(this.max&&(this.breakpoint=`(max-width: ${this.max-.02}px)`),this.min&&(this.breakpoint=`(min-width: ${this.min}px)`)):this.breakpoint="(min-width: 100vw)"}cloning(){this.clone&&this.mm.add(this.breakpoint,(()=>{for(let t=0;t<this.clone;t++){let t=this.firstElementChild,e=t.cloneNode(!0);t.after(e)}return()=>{for(;this.children.length>1;)this.removeChild(this.lastChild)}}))}skewed(){this.skew&&this.mm.add(this.breakpoint,(()=>{gsap.set(this,{skewY:this.skew,"transform-origin":"center center","min-height":`calc(${1.25*this.abs}vh + ${1.25*this.abs}vw)`})}))}animate(){this.mm.add(this.breakpoint,(()=>{gsap.defaults({overwrite:!0}),gsap.set(this.children,{"will-change":"transform"});let t=gsap.to(this.children,{duration:this.speed,x:"-100%",ease:"none",repeat:-1,scrollTrigger:{trigger:this,toggleActions:"play pause play pause",start:"-=50% bottom",end:"bottom top",onUpdate:({direction:e})=>{1===e?t.timeScale(1):t.timeScale(-1)}}}).timeScale(1).totalProgress(.5)}))}}customElements.get("marquee-content")||customElements.define("marquee-content",t),new t})();
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "marquee-content",
3
+ "version": "0.0.1",
4
+ "description": "Marquee content with GSAP",
5
+ "author": "ux-ui.pro",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/ux-ui-pro/marquee-content.git"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "src"
14
+ ],
15
+ "main": "src/js/marquee-content.js",
16
+ "bugs": {
17
+ "url": "https://github.com/ux-ui-pro/marquee-content/issues"
18
+ },
19
+ "type": "module",
20
+ "scripts": {
21
+ "serve": "gulp",
22
+ "build": "gulp build --build"
23
+ },
24
+ "dependencies": {
25
+ "gsap": "^3.11.5"
26
+ },
27
+ "devDependencies": {
28
+ "browser-sync": "^2.27.7",
29
+ "del": "^6.0.0",
30
+ "gulp": "^4.0.2",
31
+ "gulp-file-include": "^2.3.0",
32
+ "gulp-if": "^3.0.0",
33
+ "gulp-newer": "^1.4.0",
34
+ "gulp-rename": "^2.0.0",
35
+ "gulp-replace": "^1.1.3",
36
+ "webpack": "^5.69.1",
37
+ "webpack-stream": "^7.0.0"
38
+ },
39
+ "keywords": [
40
+ "text",
41
+ "fit",
42
+ "size",
43
+ "width",
44
+ "font",
45
+ "responsive"
46
+ ]
47
+ }
package/src/index.html ADDED
@@ -0,0 +1,101 @@
1
+ <!DOCTYPE html>
2
+ <html lang="ru">
3
+ <head>
4
+ <title>marquee-content</title>
5
+ <meta name="robots" content="none">
6
+ <meta charset="UTF-8">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
8
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
9
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css">
10
+ <style type="text/css">
11
+ html {
12
+ font-family: system-ui, -apple-system, "Open Sans", "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
13
+ font-size: 10px;
14
+ }
15
+
16
+ body {
17
+ margin: 0;
18
+ font-feature-settings: "kern" 1,"liga" 0;
19
+ font-size: 1.6rem;
20
+ font-weight: 400;
21
+ line-height: 1.5;
22
+ }
23
+
24
+ html,
25
+ body,
26
+ input,
27
+ textarea,
28
+ button {
29
+ -webkit-font-smoothing: subpixel-antialiased;
30
+ }
31
+
32
+ .layout {
33
+ max-width: 120rem;
34
+ margin: 0 auto;
35
+ border: 1px solid red;
36
+ border-top: none;
37
+ border-bottom: none;
38
+ }
39
+
40
+ ul {
41
+ display: flex;
42
+ list-style: none;
43
+ margin: 0; padding: 0;
44
+ }
45
+
46
+ li {
47
+ width: 200px;
48
+ margin: 0 20px;
49
+ background: lightgray;
50
+ text-align: center;
51
+ }
52
+
53
+ marquee-content {
54
+ pointer-events: none;
55
+ max-width: 100vw;
56
+ justify-content: center;
57
+ align-items: center;
58
+ display: flex;
59
+ position: relative;
60
+ overflow: hidden;
61
+ }
62
+ </style>
63
+ </head>
64
+ <body>
65
+ <div class="layout">
66
+ <marquee-content
67
+ data-mc-min="1600"
68
+ data-mc-clone="2"
69
+ data-mc-speed="30"
70
+ data-mc-skew="-2.4"
71
+ role="marquee">
72
+ <ul class="logo-set">
73
+ <li class="logo-set__item">
74
+ 1
75
+ </li>
76
+ <li class="logo-set__item">
77
+ 2
78
+ </li>
79
+ <li class="logo-set__item">
80
+ 3
81
+ </li>
82
+ <li class="logo-set__item">
83
+ 4
84
+ </li>
85
+ <li class="logo-set__item">
86
+ 5
87
+ </li>
88
+ <li class="logo-set__item">
89
+ 6
90
+ </li>
91
+ <li class="logo-set__item">
92
+ 7
93
+ </li>
94
+ </ul>
95
+ </marquee-content>
96
+ </div>
97
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.5/gsap.min.js"></script>
98
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.5/ScrollTrigger.min.js"></script>
99
+ <script src="js/marquee-content.min.js"></script>
100
+ </body>
101
+ </html>
@@ -0,0 +1,3 @@
1
+ import { MarqueeContent } from './marquee-content.js'
2
+
3
+ new MarqueeContent()
@@ -0,0 +1,92 @@
1
+ export class MarqueeContent extends HTMLElement {
2
+ constructor() {
3
+ super()
4
+
5
+ this.speed = this.dataset.mcSpeed || 20
6
+ this.clone = this.dataset.mcClone
7
+ this.skew = this.dataset.mcSkew
8
+ this.abs = (this.skew < 0) ? this.skew * -1 : this.skew
9
+ this.max = this.dataset.mcMax
10
+ this.min = this.dataset.mcMin
11
+ this.mm = gsap.matchMedia()
12
+
13
+ this.breakpoints()
14
+ this.cloning()
15
+ this.skewed()
16
+ this.animate()
17
+ }
18
+
19
+ breakpoints() {
20
+ if(this.max || this.min) {
21
+ if(this.max) {
22
+ this.breakpoint = `(max-width: ${this.max - 0.02}px)`
23
+ }
24
+
25
+ if(this.min) {
26
+ this.breakpoint = `(min-width: ${this.min}px)`
27
+ }
28
+ } else {
29
+ this.breakpoint = `(min-width: 100vw)`
30
+ }
31
+ }
32
+
33
+ cloning() {
34
+ if(!this.clone) { return }
35
+
36
+ this.mm.add(this.breakpoint, () => {
37
+ for (let i = 0; i < this.clone; i++) {
38
+ let item = this.firstElementChild
39
+ let clone = item.cloneNode(true)
40
+ item.after(clone)
41
+ }
42
+
43
+ return () => {
44
+ while (this.children.length > 1) {
45
+ this.removeChild(this.lastChild)
46
+ }
47
+ }
48
+ })
49
+ }
50
+
51
+ skewed() {
52
+ if(!this.skew) { return }
53
+
54
+ this.mm.add(this.breakpoint, () => {
55
+ gsap.set(this, {
56
+ skewY: this.skew,
57
+ 'transform-origin': 'center center',
58
+ 'min-height': `calc(${this.abs * 1.25}vh + ${this.abs * 1.25}vw)`
59
+ })
60
+ })
61
+ }
62
+
63
+ animate() {
64
+ this.mm.add(this.breakpoint, () => {
65
+ gsap.defaults({
66
+ overwrite: true
67
+ })
68
+
69
+ gsap.set(this.children, {
70
+ 'will-change': 'transform'
71
+ })
72
+
73
+ let animate = gsap.to(this.children, {
74
+ duration: this.speed,
75
+ x: '-100%',
76
+ ease: 'none',
77
+ repeat: -1,
78
+ scrollTrigger: {
79
+ trigger: this,
80
+ toggleActions: 'play pause play pause',
81
+ start: '-=50% bottom',
82
+ end: 'bottom top',
83
+ onUpdate: ({ direction }) => {
84
+ ( direction === 1 ) ? animate.timeScale(1) : animate.timeScale(-1)
85
+ }
86
+ }
87
+ }).timeScale(1).totalProgress(.5)
88
+ })
89
+ }
90
+ }
91
+
92
+ customElements.get('marquee-content') || customElements.define('marquee-content', MarqueeContent)