moving-shadow 1.1.2 → 1.1.5
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 +11 -7
- package/examples/{shadow-raised-two.html → perspective-box-shadow.html} +30 -29
- package/examples/perspective-shadow.html +2 -2
- package/examples/perspective.html +1 -1
- package/movingShadow.js +20 -23
- package/package.json +4 -4
- package/src/calculateDistance.js +2 -2
- package/src/getElePos.js +2 -2
- package/src/main.js +1 -1
- package/src/makeShadow.js +15 -18
- package/examples/shadow-two.html +0 -73
package/README.md
CHANGED
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
A JavaScript module, which creates a responsive text shadow based on mouse position (desktop) or device orientation (mobile).
|
|
5
5
|
|
|
6
|
+
As of iOS 12.2, Safari has disabled `window.getDeviceOrientation`. Until a fix is put in place, moving-shadow will not work on iOS devices.
|
|
7
|
+
|
|
6
8
|
## Examples
|
|
7
|
-
* [Flat text with moving shadow](https://
|
|
8
|
-
* [Fixed raised text with moving shadow](https://
|
|
9
|
-
* [Moving perspective text and box](https://
|
|
10
|
-
* [Moving perspective text with moving shadow](https://
|
|
11
|
-
* [Moving perspective box with moving shadow](https://
|
|
12
|
-
* [Drop shadow](https://
|
|
9
|
+
* [Flat text with moving shadow](https://oh-kay-blanket.github.io/moving-shadow/examples/shadow) - ([source](https://github.com/oh-kay-blanket/moving-shadow/blob/master/examples/shadow.html))
|
|
10
|
+
* [Fixed raised text with moving shadow](https://oh-kay-blanket.github.io/moving-shadow/examples/shadow-raised) - ([source](https://github.com/oh-kay-blanket/moving-shadow/blob/master/examples/shadow-raised.html))
|
|
11
|
+
* [Moving perspective text and box](https://oh-kay-blanket.github.io/moving-shadow/examples/perspective) - ([source](https://github.com/oh-kay-blanket/moving-shadow/blob/master/examples/perspective.html))
|
|
12
|
+
* [Moving perspective text with moving shadow](https://oh-kay-blanket.github.io/moving-shadow/examples/perspective-shadow) - ([source](https://github.com/oh-kay-blanket/moving-shadow/blob/master/examples/perspective-shadow.html))
|
|
13
|
+
* [Moving perspective box with moving shadow](https://oh-kay-blanket.github.io/moving-shadow/examples/perspective-box-shadow) - ([source](https://github.com/oh-kay-blanket/moving-shadow/blob/master/examples/perspective-box-shadow.html))
|
|
14
|
+
* [Drop shadow](https://oh-kay-blanket.github.io/moving-shadow/examples/drop-shadow) - ([source](https://github.com/oh-kay-blanket/moving-shadow/blob/master/examples/drop-shadow.html))
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
## Quick Start
|
|
@@ -28,9 +30,11 @@ const settings = {
|
|
|
28
30
|
shadowType: "shadow", // "shadow", "perspective","perspective-shadow", "dropShadow"
|
|
29
31
|
selector: "h1, h2", // tag, class, or id to apply shadow to
|
|
30
32
|
angle: 20, // height of view source. Should be between 10 - 100
|
|
33
|
+
relativeAngle:false, // false. desktop only, allows for each element to move relative to the mouse
|
|
31
34
|
diffusion: 0, // blur-radius
|
|
32
35
|
color: "#333333CC", // shadow-color or perspective color
|
|
33
|
-
|
|
36
|
+
altColor: "#333333CC", // shadow-color (perspective-shadow only)
|
|
37
|
+
shineColor: "#fff3", // reflected light (perspective-shadow only)
|
|
34
38
|
fixedShadow: null, // "5px 5px #555" to include an optional fixed shadow
|
|
35
39
|
xOffset: 0, // X offset value, set to max fixedShadow x offset
|
|
36
40
|
yOffset: 0 // Y offset value, set to max fixedShadow y offset
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
7
|
-
<link href="https://fonts.googleapis.com/css2?family=Montserrat:
|
|
7
|
+
<link href="https://fonts.googleapis.com/css2?family=Montserrat:display=swap" rel="stylesheet">
|
|
8
8
|
<!-- <script src="../movingShadow.js"></script> -->
|
|
9
9
|
<script src="https://unpkg.com/moving-shadow"></script>
|
|
10
10
|
<title>Shadow Example | Moving Shadow</title>
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
|
13
13
|
<div class="container">
|
|
14
|
-
<h1>
|
|
14
|
+
<h1>wapor vave</h1>
|
|
15
15
|
<div class="in-out">
|
|
16
|
-
<
|
|
17
|
-
<
|
|
16
|
+
<button>exit</button>
|
|
17
|
+
<button>enter</button>
|
|
18
18
|
</div>
|
|
19
19
|
</div>
|
|
20
20
|
</body>
|
|
@@ -35,8 +35,8 @@ html, body {
|
|
|
35
35
|
justify-content: center;
|
|
36
36
|
align-items: center;
|
|
37
37
|
height: 100%;
|
|
38
|
-
background-color: #
|
|
39
|
-
color: #
|
|
38
|
+
background-color: #222;
|
|
39
|
+
color: #222;
|
|
40
40
|
font-size: 4rem;
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -60,39 +60,40 @@ h1 {
|
|
|
60
60
|
display: flex;
|
|
61
61
|
justify-content: space-around;
|
|
62
62
|
align-items: center;
|
|
63
|
-
width:
|
|
63
|
+
width: 60%;
|
|
64
|
+
}
|
|
65
|
+
@min(width: 768px) {
|
|
66
|
+
.in-out {
|
|
67
|
+
width: 30%;
|
|
68
|
+
}
|
|
64
69
|
}
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
button {
|
|
72
|
+
background-color: #222;
|
|
73
|
+
color: #44f;
|
|
74
|
+
transition: color .35s;
|
|
75
|
+
border: none;
|
|
76
|
+
border-radius: 10px;
|
|
77
|
+
padding: 12px;
|
|
78
|
+
font-size: 1.2rem;
|
|
69
79
|
}
|
|
70
80
|
|
|
71
|
-
|
|
72
|
-
color: #
|
|
73
|
-
transition: color
|
|
74
|
-
cursor: pointer;
|
|
81
|
+
button:hover {
|
|
82
|
+
color: #f2c;
|
|
83
|
+
transition: color .35s;
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
</style>
|
|
78
87
|
|
|
79
88
|
<script>
|
|
80
|
-
const fixedColor = "#665200";
|
|
81
89
|
const settings = {
|
|
82
|
-
selector: "h1,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
2px 2px ${fixedColor},
|
|
90
|
-
3px 3px ${fixedColor},
|
|
91
|
-
4px 4px ${fixedColor},
|
|
92
|
-
5px 5px ${fixedColor},
|
|
93
|
-
6px 6px ${fixedColor},
|
|
94
|
-
7px 7px ${fixedColor},
|
|
95
|
-
8px 8px ${fixedColor}`// "5px 5px #555" if you want to includ an optional fixed shadow
|
|
90
|
+
selector: "h1, button", // targets class or id
|
|
91
|
+
shadowType: "perspective-shadow",
|
|
92
|
+
angle: 80,
|
|
93
|
+
color: "#f22", // shadow
|
|
94
|
+
altColor: "#0003", // shadow
|
|
95
|
+
shineColor: "#44f",
|
|
96
|
+
fixedShadow: `0px 0px 10px #44fc`
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
movingShadow(settings);
|
|
@@ -59,10 +59,10 @@ p {
|
|
|
59
59
|
const settings = {
|
|
60
60
|
selector: "h1, h3", // targets class or id
|
|
61
61
|
shadowType: "perspective-shadow", // "shadow", "dropShadow", "perspective"
|
|
62
|
-
angle:
|
|
62
|
+
angle: 60, // Sets height of light source. Should be > 10 && < 100. Default 20.
|
|
63
63
|
diffusion: 0, // blur-radius
|
|
64
64
|
color: "white", // shadow-color
|
|
65
|
-
|
|
65
|
+
altColor: "#eeb377",
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
movingShadow(settings);
|
package/movingShadow.js
CHANGED
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
const getElePos = element => {
|
|
69
|
+
const getElePos = (element, relativeAngle) => {
|
|
70
70
|
|
|
71
71
|
// Use same shadow for mobile
|
|
72
|
-
if (event.type === 'deviceorientation') {
|
|
72
|
+
if (event.type === 'deviceorientation' || !relativeAngle) {
|
|
73
73
|
// Get device window specs
|
|
74
74
|
const rect = {
|
|
75
75
|
centerX: Math.round(window.innerWidth/2),
|
|
@@ -87,12 +87,12 @@
|
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
-
const calculateDistance = (element, viewPos, { angle=20 } = {}) => {
|
|
90
|
+
const calculateDistance = (element, viewPos, { angle=20, relativeAngle=false } = {}) => {
|
|
91
91
|
|
|
92
92
|
let distance = {};
|
|
93
93
|
|
|
94
94
|
// Get element position
|
|
95
|
-
const elePos = getElePos(element);
|
|
95
|
+
const elePos = getElePos(element, relativeAngle);
|
|
96
96
|
|
|
97
97
|
// Find difference between view position & element
|
|
98
98
|
distance.x = Math.round(viewPos.x - elePos.centerX)/angle;
|
|
@@ -121,7 +121,8 @@
|
|
|
121
121
|
angle = 20,
|
|
122
122
|
diffusion = 0,
|
|
123
123
|
color = "#333c",
|
|
124
|
-
|
|
124
|
+
altColor = "#333c",
|
|
125
|
+
shineColor = "#fff3",
|
|
125
126
|
fixedShadow,
|
|
126
127
|
xOffset = 0,
|
|
127
128
|
yOffset = 0
|
|
@@ -146,7 +147,7 @@
|
|
|
146
147
|
if (shadowType === "shadow") {
|
|
147
148
|
|
|
148
149
|
// Build stacked shadow until farthestPoint
|
|
149
|
-
for (let i = 1; i < farthestPoint; i+=
|
|
150
|
+
for (let i = 1; i < farthestPoint; i+=1) {
|
|
150
151
|
shadowArr.push(`
|
|
151
152
|
${i/farthestPoint*(-distance.x)+xOffset}px
|
|
152
153
|
${i/farthestPoint*(-distance.y)+yOffset}px
|
|
@@ -159,36 +160,33 @@
|
|
|
159
160
|
} else if (shadowType === "perspective-shadow") {
|
|
160
161
|
|
|
161
162
|
// Perspective
|
|
162
|
-
for (let i = 1; i < farthestPoint; i+=
|
|
163
|
+
for (let i = 1; i < farthestPoint; i+=1) {
|
|
163
164
|
shadowArr.push(`
|
|
164
165
|
${i/farthestPoint*(distance.x)+xOffset}px
|
|
165
166
|
${i/farthestPoint*(distance.y)+yOffset}px
|
|
166
|
-
${diffusion}px
|
|
167
167
|
${color}
|
|
168
168
|
`);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
// Normal shadow
|
|
172
|
-
for (let i = 1; i < farthestPoint; i+=
|
|
172
|
+
for (let i = 1; i < (farthestPoint/1.5); i+=1) {
|
|
173
173
|
shadowArr.push(`
|
|
174
|
-
${i/farthestPoint*(-distance.x*1)+xOffset}px
|
|
175
|
-
${i/farthestPoint*(-distance.y*1)+yOffset}px
|
|
176
|
-
|
|
177
|
-
${
|
|
174
|
+
${i/(farthestPoint/1.5)*(-distance.x*1)+xOffset}px
|
|
175
|
+
${i/(farthestPoint/1.5)*(-distance.y*1)+yOffset}px
|
|
176
|
+
${diffusion}px
|
|
177
|
+
${altColor}
|
|
178
178
|
`);
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
|
|
182
182
|
|
|
183
183
|
// Reflecting light
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
`);
|
|
191
|
-
}
|
|
184
|
+
shadowArr.push(`
|
|
185
|
+
${(distance.x)+xOffset}px
|
|
186
|
+
${(distance.y)+yOffset}px
|
|
187
|
+
3px
|
|
188
|
+
${shineColor}
|
|
189
|
+
`);
|
|
192
190
|
|
|
193
191
|
// Shift element
|
|
194
192
|
element.style.left = `${(-distance.x)+xOffset}px`;
|
|
@@ -202,7 +200,6 @@
|
|
|
202
200
|
shadowArr.push(`
|
|
203
201
|
${i/farthestPoint*(distance.x)+xOffset}px
|
|
204
202
|
${i/farthestPoint*(distance.y)+yOffset}px
|
|
205
|
-
${diffusion}px
|
|
206
203
|
${color}
|
|
207
204
|
`);
|
|
208
205
|
}
|
|
@@ -242,7 +239,7 @@
|
|
|
242
239
|
// Function to parse settings and apply default values
|
|
243
240
|
const processSettings = (settings) => {
|
|
244
241
|
// Default settings if no params passed
|
|
245
|
-
settings = settings ? settings : {selector:"h1,h2", shadowType:"shadow", inset:false};
|
|
242
|
+
settings = settings ? settings : {selector:"h1,h2", shadowType:"shadow", inset: false};
|
|
246
243
|
settings.selector = settings.selector ? settings.selector : "h1,h2";
|
|
247
244
|
settings.shadowType = settings.shadowType ? settings.shadowType : "shadow";
|
|
248
245
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moving-shadow",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "A JavaScript module, which creates a responsive text shadow based on mouse position (desktop) or device orientation (mobile)",
|
|
5
5
|
"main": "movingShadow.js",
|
|
6
6
|
"directories": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/
|
|
15
|
+
"url": "git+https://github.com/oh-kay-blanket/moving-shadow.git"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"text-shadow",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"author": "gaijinbrandybuck",
|
|
28
28
|
"license": "ISC",
|
|
29
29
|
"bugs": {
|
|
30
|
-
"url": "https://github.com/
|
|
30
|
+
"url": "https://github.com/oh-kay-blanket/moving-shadow/issues"
|
|
31
31
|
},
|
|
32
|
-
"homepage": "https://github.com/
|
|
32
|
+
"homepage": "https://github.com/oh-kay-blanket/moving-shadow#readme"
|
|
33
33
|
}
|
package/src/calculateDistance.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import getElePos from "./getElePos";
|
|
2
2
|
|
|
3
|
-
const calculateDistance = (element, viewPos, { angle=20 } = {}) => {
|
|
3
|
+
const calculateDistance = (element, viewPos, { angle=20, relativeAngle=false } = {}) => {
|
|
4
4
|
|
|
5
5
|
let distance = {};
|
|
6
6
|
|
|
7
7
|
// Get element position
|
|
8
|
-
const elePos = getElePos(element);
|
|
8
|
+
const elePos = getElePos(element, relativeAngle);
|
|
9
9
|
|
|
10
10
|
// Find difference between view position & element
|
|
11
11
|
distance.x = Math.round(viewPos.x - elePos.centerX)/angle;
|
package/src/getElePos.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const getElePos = element => {
|
|
1
|
+
const getElePos = (element, relativeAngle) => {
|
|
2
2
|
|
|
3
3
|
// Use same shadow for mobile
|
|
4
|
-
if (event.type === 'deviceorientation') {
|
|
4
|
+
if (event.type === 'deviceorientation' || !relativeAngle) {
|
|
5
5
|
// Get device window specs
|
|
6
6
|
const rect = {
|
|
7
7
|
centerX: Math.round(window.innerWidth/2),
|
package/src/main.js
CHANGED
|
@@ -9,7 +9,7 @@ const movingShadow = settings => {
|
|
|
9
9
|
// Function to parse settings and apply default values
|
|
10
10
|
const processSettings = (settings) => {
|
|
11
11
|
// Default settings if no params passed
|
|
12
|
-
settings = settings ? settings : {selector:"h1,h2", shadowType:"shadow", inset:false};
|
|
12
|
+
settings = settings ? settings : {selector:"h1,h2", shadowType:"shadow", inset: false};
|
|
13
13
|
settings.selector = settings.selector ? settings.selector : "h1,h2";
|
|
14
14
|
settings.shadowType = settings.shadowType ? settings.shadowType : "shadow";
|
|
15
15
|
|
package/src/makeShadow.js
CHANGED
|
@@ -4,7 +4,8 @@ const makeShadow = (element, distance, {
|
|
|
4
4
|
angle = 20,
|
|
5
5
|
diffusion = 0,
|
|
6
6
|
color = "#333c",
|
|
7
|
-
|
|
7
|
+
altColor = "#333c",
|
|
8
|
+
shineColor = "#fff3",
|
|
8
9
|
fixedShadow,
|
|
9
10
|
xOffset = 0,
|
|
10
11
|
yOffset = 0
|
|
@@ -29,7 +30,7 @@ const makeShadow = (element, distance, {
|
|
|
29
30
|
if (shadowType === "shadow") {
|
|
30
31
|
|
|
31
32
|
// Build stacked shadow until farthestPoint
|
|
32
|
-
for (let i = 1; i < farthestPoint; i+=
|
|
33
|
+
for (let i = 1; i < farthestPoint; i+=1) {
|
|
33
34
|
shadowArr.push(`
|
|
34
35
|
${i/farthestPoint*(-distance.x)+xOffset}px
|
|
35
36
|
${i/farthestPoint*(-distance.y)+yOffset}px
|
|
@@ -42,36 +43,33 @@ const makeShadow = (element, distance, {
|
|
|
42
43
|
} else if (shadowType === "perspective-shadow") {
|
|
43
44
|
|
|
44
45
|
// Perspective
|
|
45
|
-
for (let i = 1; i < farthestPoint; i+=
|
|
46
|
+
for (let i = 1; i < farthestPoint; i+=1) {
|
|
46
47
|
shadowArr.push(`
|
|
47
48
|
${i/farthestPoint*(distance.x)+xOffset}px
|
|
48
49
|
${i/farthestPoint*(distance.y)+yOffset}px
|
|
49
|
-
${diffusion}px
|
|
50
50
|
${color}
|
|
51
51
|
`);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// Normal shadow
|
|
55
|
-
for (let i = 1; i < farthestPoint; i+=
|
|
55
|
+
for (let i = 1; i < (farthestPoint/1.5); i+=1) {
|
|
56
56
|
shadowArr.push(`
|
|
57
|
-
${i/farthestPoint*(-distance.x*1)+xOffset}px
|
|
58
|
-
${i/farthestPoint*(-distance.y*1)+yOffset}px
|
|
59
|
-
|
|
60
|
-
${
|
|
57
|
+
${i/(farthestPoint/1.5)*(-distance.x*1)+xOffset}px
|
|
58
|
+
${i/(farthestPoint/1.5)*(-distance.y*1)+yOffset}px
|
|
59
|
+
${diffusion}px
|
|
60
|
+
${altColor}
|
|
61
61
|
`);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
// Reflecting light
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
`);
|
|
74
|
-
}
|
|
67
|
+
shadowArr.push(`
|
|
68
|
+
${(distance.x)+xOffset}px
|
|
69
|
+
${(distance.y)+yOffset}px
|
|
70
|
+
3px
|
|
71
|
+
${shineColor}
|
|
72
|
+
`);
|
|
75
73
|
|
|
76
74
|
// Shift element
|
|
77
75
|
element.style.left = `${(-distance.x)+xOffset}px`;
|
|
@@ -85,7 +83,6 @@ const makeShadow = (element, distance, {
|
|
|
85
83
|
shadowArr.push(`
|
|
86
84
|
${i/farthestPoint*(distance.x)+xOffset}px
|
|
87
85
|
${i/farthestPoint*(distance.y)+yOffset}px
|
|
88
|
-
${diffusion}px
|
|
89
86
|
${color}
|
|
90
87
|
`);
|
|
91
88
|
}
|
package/examples/shadow-two.html
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
7
|
-
<!-- <script src="../movingShadow.js"></script> -->
|
|
8
|
-
<script src="https://unpkg.com/moving-shadow"></script>
|
|
9
|
-
<title>Shadow Example | Moving Shadow</title>
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
<div class="container"></div>
|
|
13
|
-
</body>
|
|
14
|
-
</html>
|
|
15
|
-
|
|
16
|
-
<style>
|
|
17
|
-
html, body {
|
|
18
|
-
margin: 0;
|
|
19
|
-
overflow-x: hidden;
|
|
20
|
-
overflow-y: hidden;
|
|
21
|
-
height: 100vh;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.container {
|
|
25
|
-
display: flex;
|
|
26
|
-
flex-direction: column;
|
|
27
|
-
justify-content: space-around;
|
|
28
|
-
align-items: center;
|
|
29
|
-
height: 100%;
|
|
30
|
-
background-color: #f8f8f8;
|
|
31
|
-
color: #222;
|
|
32
|
-
font-size: 2rem;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@media (max-width: 600px) {
|
|
36
|
-
.container {
|
|
37
|
-
font-size: 1rem;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.container > div {
|
|
42
|
-
display: flex;
|
|
43
|
-
justify-content: space-around;
|
|
44
|
-
align-items: center;
|
|
45
|
-
width: 100%;
|
|
46
|
-
}
|
|
47
|
-
</style>
|
|
48
|
-
|
|
49
|
-
<script>
|
|
50
|
-
|
|
51
|
-
const text = "One ring to rule them all, One ring to find them, One ring to bring them all, And in the darkness bind them."
|
|
52
|
-
const textBreaks = text.split(',');
|
|
53
|
-
let fullHTML = [];
|
|
54
|
-
textBreaks.forEach(line => {
|
|
55
|
-
let elements = [];
|
|
56
|
-
elements.push("<div>");
|
|
57
|
-
const words = line.split(" ");
|
|
58
|
-
words.forEach(word => {
|
|
59
|
-
elements.push(`<h4>${word}</h4>`);
|
|
60
|
-
})
|
|
61
|
-
elements.push("</div>");
|
|
62
|
-
fullHTML.push(elements.join(""));
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
document.querySelector(".container").insertAdjacentHTML('afterbegin', fullHTML.join(""));
|
|
66
|
-
|
|
67
|
-
const settings = {
|
|
68
|
-
selector: "h4",
|
|
69
|
-
color: "#790606", // shadow-color
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
movingShadow(settings);
|
|
73
|
-
</script>
|