nodality 1.0.0-beta.2 → 1.0.0-beta.21
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 +21 -0
- package/README.md +108 -0
- package/dist/animator.cjs.js +1 -1
- package/dist/animator.esm.js +1 -1
- package/dist/appleanim.cjs.js +1 -0
- package/dist/appleanim.esm.js +1 -0
- package/dist/audionew.cjs.js +1 -1
- package/dist/audionew.esm.js +1 -1
- package/dist/base.cjs.js +1 -1
- package/dist/base.esm.js +1 -1
- package/dist/betaDesktopBar.esm.js +1 -1
- package/dist/betaMobileBar.esm.js +1 -1
- package/dist/bundle.umd.js +1 -1
- package/dist/button.cjs.js +1 -1
- package/dist/button.esm.js +1 -1
- package/dist/cardGetter.cjs.js +1 -1
- package/dist/cardGetter.esm.js +1 -1
- package/dist/center.cjs.js +1 -1
- package/dist/center.esm.js +1 -1
- package/dist/checkbox.cjs.js +1 -1
- package/dist/checkbox.esm.js +1 -1
- package/dist/code.cjs.js +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/container.cjs.js +1 -1
- package/dist/container.esm.js +1 -1
- package/dist/datalist.cjs.js +1 -1
- package/dist/datalist.esm.js +1 -1
- package/dist/designer.cjs.js +1 -1
- package/dist/designer.esm.js +1 -1
- package/dist/dropdown.cjs.js +1 -1
- package/dist/dropdown.esm.js +1 -1
- package/dist/elementMapper.cjs.js +1 -1
- package/dist/elementMapper.esm.js +1 -1
- package/dist/finalresult.esm.js +1 -1
- package/dist/flexCard.cjs.js +1 -1
- package/dist/flexCard.esm.js +1 -1
- package/dist/flexGrid.cjs.js +1 -1
- package/dist/flexGrid.esm.js +1 -1
- package/dist/flexRow.cjs.js +1 -1
- package/dist/flexRow.esm.js +1 -1
- package/dist/floatingInput.cjs.js +1 -1
- package/dist/floatingInput.esm.js +1 -1
- package/dist/free.cjs.js +1 -1
- package/dist/free.esm.js +1 -1
- package/dist/horizontalScroller.esm.js +1 -1
- package/dist/image.cjs.js +1 -1
- package/dist/image.esm.js +1 -1
- package/dist/imagePicker.cjs.js +1 -1
- package/dist/imagePicker.esm.js +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/link.cjs.js +1 -1
- package/dist/link.esm.js +1 -1
- package/dist/linkGetter.cjs.js +1 -1
- package/dist/linkGetter.esm.js +1 -1
- package/dist/metaAdder.cjs.js +1 -1
- package/dist/metaAdder.esm.js +1 -1
- package/dist/modal2025.cjs.js +1 -1
- package/dist/modal2025.esm.js +1 -1
- package/dist/multiswitchers.esm.js +1 -1
- package/dist/newNavBar.cjs.js +1 -1
- package/dist/newNavBar.esm.js +1 -1
- package/dist/picker.cjs.js +1 -1
- package/dist/picker.esm.js +1 -1
- package/dist/progress.cjs.js +1 -1
- package/dist/progress.esm.js +1 -1
- package/dist/radio.cjs.js +1 -1
- package/dist/radio.esm.js +1 -1
- package/dist/range.cjs.js +1 -1
- package/dist/range.esm.js +1 -1
- package/dist/scrollvideo.cjs.js +1 -0
- package/dist/scrollvideo.esm.js +1 -0
- package/dist/sideBar.cjs.js +1 -1
- package/dist/sideBar.esm.js +1 -1
- package/dist/sideNavBar.cjs.js +1 -1
- package/dist/sideNavBar.esm.js +1 -1
- package/dist/simpleBar.cjs.js +1 -1
- package/dist/simpleBar.esm.js +1 -1
- package/dist/stack.cjs.js +1 -1
- package/dist/stack.esm.js +1 -1
- package/dist/stacker.cjs.js +1 -0
- package/dist/stacker.esm.js +1 -0
- package/dist/table.cjs.js +1 -1
- package/dist/table.esm.js +1 -1
- package/dist/text.cjs.js +1 -1
- package/dist/text.esm.js +1 -1
- package/dist/textField.cjs.js +1 -1
- package/dist/textField.esm.js +1 -1
- package/dist/transformanim.cjs.js +1 -0
- package/dist/transformanim.esm.js +1 -0
- package/dist/wrap.cjs.js +1 -1
- package/dist/wrap.esm.js +1 -1
- package/dist/zoomCard.cjs.js +1 -1
- package/dist/zoomCard.esm.js +1 -1
- package/layout/index.js +16 -0
- package/layout/sideNavBar.js +1 -1
- package/layout/text.js +2 -0
- package/lib/AppleAnim.js +789 -0
- package/lib/Stacker.js +36 -0
- package/lib/TransformAnim.js +514 -0
- package/lib/designer.js +250 -6
- package/lib/elementMapper.js +7 -29
- package/lib/scrollvideo.js +125 -0
- package/package.json +18 -4
package/lib/designer.js
CHANGED
|
@@ -52,6 +52,12 @@ import { LinkStyler } from "../lib/linkGetter.js";
|
|
|
52
52
|
import { CardGen } from "../lib/cardGetter.js";
|
|
53
53
|
import {Simple} from "../layout/gridSwitcher.js";
|
|
54
54
|
|
|
55
|
+
// ANIM
|
|
56
|
+
import {KeyframeAnim} from "../lib/appleAnim.js";
|
|
57
|
+
import {TransformAnim} from "../lib/transformanim.js";
|
|
58
|
+
import {Stacker} from "../lib/stacker.js";
|
|
59
|
+
import {ScrollVideo} from "../lib/scrollvideo.js";
|
|
60
|
+
console.log("SO");
|
|
55
61
|
// Audio, progress, TextField, import navFactor
|
|
56
62
|
class Des {
|
|
57
63
|
constructor() {
|
|
@@ -82,8 +88,46 @@ class Des {
|
|
|
82
88
|
},
|
|
83
89
|
|
|
84
90
|
complex: {
|
|
85
|
-
code: `new Wrapper()
|
|
86
|
-
|
|
91
|
+
code: `new Wrapper()
|
|
92
|
+
.set({
|
|
93
|
+
|
|
94
|
+
responsive: {
|
|
95
|
+
ranges: ["700px", "1200px", "1400px"],
|
|
96
|
+
sequence: "col-row-col"
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
.add([
|
|
100
|
+
new Image("img/wix.jpeg").set({
|
|
101
|
+
width: "100%",
|
|
102
|
+
height: "200px",
|
|
103
|
+
objectFit: "cover"
|
|
104
|
+
}),
|
|
105
|
+
|
|
106
|
+
new Wrapper().set({
|
|
107
|
+
responsive: {
|
|
108
|
+
ranges: ["700px", "1200px", "1400px"],
|
|
109
|
+
sequence: "col-col-row"
|
|
110
|
+
}
|
|
111
|
+
}).add([
|
|
112
|
+
new Text("Running in the desert").set({
|
|
113
|
+
size: "S3",
|
|
114
|
+
font: "Arial",
|
|
115
|
+
color: "orange"
|
|
116
|
+
}),
|
|
117
|
+
|
|
118
|
+
new Text("This is example content").set({
|
|
119
|
+
exact: "1rem",
|
|
120
|
+
font: "Arial"
|
|
121
|
+
}),
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
new Image("img/wix.jpeg").set({
|
|
125
|
+
width: "100%",
|
|
126
|
+
height: "300px",
|
|
127
|
+
objectFit: "cover"
|
|
128
|
+
})
|
|
129
|
+
])
|
|
130
|
+
])`
|
|
87
131
|
}, ops: {
|
|
88
132
|
miami: {
|
|
89
133
|
blast: {
|
|
@@ -127,7 +171,144 @@ class Des {
|
|
|
127
171
|
},
|
|
128
172
|
|
|
129
173
|
grid: {
|
|
130
|
-
code: `new Simple()
|
|
174
|
+
code: ` new Simple()
|
|
175
|
+
.set({
|
|
176
|
+
gap: "1rem"
|
|
177
|
+
})
|
|
178
|
+
.react([{
|
|
179
|
+
at: "0px",
|
|
180
|
+
template: [
|
|
181
|
+
"eeeeee",
|
|
182
|
+
"eeeeee",
|
|
183
|
+
"abbbbb",
|
|
184
|
+
"abbbbb",
|
|
185
|
+
"abbbbb",
|
|
186
|
+
"cccccc",
|
|
187
|
+
"cccccc",
|
|
188
|
+
"dddddd"
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
{
|
|
193
|
+
at: "900px",
|
|
194
|
+
color: "orange",
|
|
195
|
+
template: [
|
|
196
|
+
"aaaccc",
|
|
197
|
+
"aaaccc",
|
|
198
|
+
"bbbbbb",
|
|
199
|
+
"dddddd",
|
|
200
|
+
"eeeeee"
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
{
|
|
205
|
+
at: "1200px",
|
|
206
|
+
color: "purple",
|
|
207
|
+
template: [
|
|
208
|
+
"cccaaa",
|
|
209
|
+
"cccaaa",
|
|
210
|
+
"bbbbbb",
|
|
211
|
+
"dddddd",
|
|
212
|
+
"eeeeee"
|
|
213
|
+
]
|
|
214
|
+
},
|
|
215
|
+
])
|
|
216
|
+
.add([
|
|
217
|
+
new Wrapper().set({
|
|
218
|
+
pad: [{
|
|
219
|
+
a: 20
|
|
220
|
+
}],
|
|
221
|
+
background: "#ecf0f1",
|
|
222
|
+
radius: "1.7rem"
|
|
223
|
+
}).add([
|
|
224
|
+
new Text("NEW PRODUCT").set({
|
|
225
|
+
exact: "1rem",
|
|
226
|
+
font: "Oswald",
|
|
227
|
+
width: "100%"
|
|
228
|
+
}),
|
|
229
|
+
new Text("Feel").set({
|
|
230
|
+
fluidc: "S2",
|
|
231
|
+
font: "Oswald",
|
|
232
|
+
width: "100%",
|
|
233
|
+
color: "black"
|
|
234
|
+
}),
|
|
235
|
+
new Text("Speed").set({
|
|
236
|
+
exact: "7rem",
|
|
237
|
+
font: "Oswald",
|
|
238
|
+
width: "100%",
|
|
239
|
+
color: "#3498db"
|
|
240
|
+
}),
|
|
241
|
+
]),
|
|
242
|
+
|
|
243
|
+
new Wrapper().set({
|
|
244
|
+
pad: [{
|
|
245
|
+
a: 20
|
|
246
|
+
}],
|
|
247
|
+
background: "#ecf0f1",
|
|
248
|
+
radius: "1.7rem"
|
|
249
|
+
}).add([
|
|
250
|
+
new Text("TOP QUALITY").set({
|
|
251
|
+
exact: "1rem",
|
|
252
|
+
font: "Oswald",
|
|
253
|
+
width: "100%"
|
|
254
|
+
}),
|
|
255
|
+
new Text("Amazing animals").set({
|
|
256
|
+
fluidc: "S2",
|
|
257
|
+
font: "Oswald",
|
|
258
|
+
width: "100%",
|
|
259
|
+
color: "black"
|
|
260
|
+
}),
|
|
261
|
+
|
|
262
|
+
new Text("Seals are intelligent, agile marine mammals found in oceans around the world, known for their streamlined bodies, flippers, and ability to thrive both in water and on land. Belonging to the pinniped family, they are divided into true seals, which lack external ears, and eared seals like sea lions, which are more mobile on land. Seals feed primarily on fish and squid, using their sensitive whiskers to detect prey underwater, and can dive to great depths while holding their breath for extended periods. Adapted to cold environments with thick blubber for insulation, seals play a crucial role in marine ecosystems but face threats from climate change, pollution, and human activity, making conservation efforts increasingly important.")
|
|
263
|
+
.set({
|
|
264
|
+
font: "Arial",
|
|
265
|
+
exact: "1.3rem"
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
]),
|
|
269
|
+
|
|
270
|
+
new Wrapper().set({
|
|
271
|
+
radius: "1.7rem",
|
|
272
|
+
overflow: "hidden"
|
|
273
|
+
|
|
274
|
+
}).add([
|
|
275
|
+
|
|
276
|
+
new Image("https://cdn.pixabay.com/photo/2017/02/09/18/40/seal-2053165_640.jpg", "exact").set({
|
|
277
|
+
width: "100%",
|
|
278
|
+
height: "420px",
|
|
279
|
+
minHeight: "100px",
|
|
280
|
+
objectFit: "cover"
|
|
281
|
+
|
|
282
|
+
})
|
|
283
|
+
]),
|
|
284
|
+
|
|
285
|
+
new Wrapper().set({
|
|
286
|
+
pad: [{
|
|
287
|
+
a: 20
|
|
288
|
+
}],
|
|
289
|
+
background: "#ecf0f1",
|
|
290
|
+
radius: "1.7rem",
|
|
291
|
+
}).add([
|
|
292
|
+
new Text("Welcome seals").set({
|
|
293
|
+
fluidc: "S3",
|
|
294
|
+
font: "Oswald",
|
|
295
|
+
color: "black"
|
|
296
|
+
}),
|
|
297
|
+
|
|
298
|
+
]),
|
|
299
|
+
new Wrapper().set({
|
|
300
|
+
mc: true,
|
|
301
|
+
pad: [{
|
|
302
|
+
a: 20
|
|
303
|
+
}],
|
|
304
|
+
background: "#ecf0f1",
|
|
305
|
+
radius: "1.7rem",
|
|
306
|
+
|
|
307
|
+
}).add([new Text("Top line").set({
|
|
308
|
+
font: "Arial",
|
|
309
|
+
exact: "1.3rem"
|
|
310
|
+
}), ]),
|
|
311
|
+
])`, // Rest omitted for brevity
|
|
131
312
|
},
|
|
132
313
|
|
|
133
314
|
flexRow: (colat) => ({
|
|
@@ -135,7 +316,23 @@ class Des {
|
|
|
135
316
|
code: `new FlexRow().set({border: ["all", "3px"], colat: "600px"}).items([new Image(...), new Image(...), new Image(...)])`,
|
|
136
317
|
},
|
|
137
318
|
text: {
|
|
138
|
-
code: `new FlexRow().set({
|
|
319
|
+
code: `new FlexRow().set({}).items([
|
|
320
|
+
|
|
321
|
+
new Text("This").set({
|
|
322
|
+
size: "S3"
|
|
323
|
+
}),
|
|
324
|
+
|
|
325
|
+
new Text("is").set({
|
|
326
|
+
size: "S3",
|
|
327
|
+
text: "Hello"
|
|
328
|
+
}),
|
|
329
|
+
|
|
330
|
+
new Text("row.").set({
|
|
331
|
+
size: "S3",
|
|
332
|
+
text: "Hello"
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
])`,
|
|
139
336
|
},
|
|
140
337
|
}),
|
|
141
338
|
|
|
@@ -561,7 +758,7 @@ console.log(duration);
|
|
|
561
758
|
console.log(`----------------------------LLL ${i} ${customOptions.length}`);
|
|
562
759
|
|
|
563
760
|
|
|
564
|
-
const matchEls = ["h1", "h2", "h3", "h4", "h5", "h6"].includes(el.type) || el.type === "img" || el.type === "a" || /*el.type == "modal" ||*/ el.type == "slider"
|
|
761
|
+
const matchEls = ["h1", "h2", "h3", "h4", "h5", "h6"].includes(el.type) || el.type === "img" || el.type === "a" || /*el.type == "modal" ||*/ el.type == "slider" /*|| el.type == "table"*/;
|
|
565
762
|
|
|
566
763
|
if (matchEls) {
|
|
567
764
|
|
|
@@ -580,6 +777,29 @@ console.log(duration);
|
|
|
580
777
|
this.ready2Render.push(ela);
|
|
581
778
|
ela = ela.render();
|
|
582
779
|
|
|
780
|
+
} else if (el.type === "table"){
|
|
781
|
+
this.code.push(`
|
|
782
|
+
new Table()
|
|
783
|
+
.add([
|
|
784
|
+
{ abbr: "AUIUI/AK9PT", name: "Pokročilé mobilní technologie", grade: "A", date: "09.01.2024" },
|
|
785
|
+
{ abbr: "AUIUI/AK9PT", name: "Pokročilé mobilní technologie", grade: "A", date: "09.01.2024" },
|
|
786
|
+
{ abbr: "AUIUI/AK9PT", name: "Pokročilé mobilní technologie", grade: "A", date: "09.01.2024" }
|
|
787
|
+
])
|
|
788
|
+
.set({
|
|
789
|
+
cellPadding: "0.3em",
|
|
790
|
+
cellAlign: "center",
|
|
791
|
+
style: {
|
|
792
|
+
font: "Arial"
|
|
793
|
+
},
|
|
794
|
+
headStyle: {
|
|
795
|
+
color: "white",
|
|
796
|
+
background: "#ff6d22"
|
|
797
|
+
},
|
|
798
|
+
border: "2px solid black",
|
|
799
|
+
center: true,
|
|
800
|
+
borderRadius: 2.2
|
|
801
|
+
})
|
|
802
|
+
`);
|
|
583
803
|
} else if (el.type === "grid") {
|
|
584
804
|
this.code.push(
|
|
585
805
|
this.stor.grid.code
|
|
@@ -842,6 +1062,7 @@ console.log(duration);
|
|
|
842
1062
|
|
|
843
1063
|
let preo = document.createElement("pre");
|
|
844
1064
|
preo.style.marginTop = "100px";
|
|
1065
|
+
preo.style.overflow = "scroll";
|
|
845
1066
|
return this;
|
|
846
1067
|
}
|
|
847
1068
|
|
|
@@ -862,11 +1083,34 @@ console.log(duration);
|
|
|
862
1083
|
}
|
|
863
1084
|
}
|
|
864
1085
|
|
|
1086
|
+
const layout = {
|
|
1087
|
+
Text, Image, Link, FlexRow, UINavBar, Free, Audio, Progress, Center, Code,
|
|
1088
|
+
Stack, Wrapper, MetaAdder, Table, Dropdown, Modal, TextField, Card,
|
|
1089
|
+
Wrap, FlexGrid, ZoomCard, Switcher, MobileBar, DesktopBar, SideNav, Spacer,
|
|
1090
|
+
};
|
|
1091
|
+
|
|
1092
|
+
const formComponents = {
|
|
1093
|
+
FloatingInput, Range, RadioGroup, Picker, FilePickera,
|
|
1094
|
+
DataList, Base, Form, Button, Slider, Video, Checkbox,
|
|
1095
|
+
};
|
|
1096
|
+
|
|
1097
|
+
const libs = {
|
|
1098
|
+
ElementMapper, Animator, LinkStyler, CardGen, Simple,
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1101
|
+
|
|
1102
|
+
const components = {
|
|
1103
|
+
...layout,
|
|
1104
|
+
...formComponents,
|
|
1105
|
+
...libs,
|
|
1106
|
+
};
|
|
1107
|
+
|
|
865
1108
|
for (var i = 0; i < this.code.length; i++) {
|
|
866
1109
|
let sub = this.code[i];
|
|
867
1110
|
console.log("SUBO");
|
|
868
1111
|
console.log(sub);
|
|
869
|
-
|
|
1112
|
+
new Function(...Object.keys(components), sub)(...Object.values(components));
|
|
1113
|
+
// eval(`${sub}`);
|
|
870
1114
|
}
|
|
871
1115
|
}
|
|
872
1116
|
}
|
package/lib/elementMapper.js
CHANGED
|
@@ -58,9 +58,9 @@ class ElementMapper { // 22:09:58 04/11/2024
|
|
|
58
58
|
return this.protoNav(obj);
|
|
59
59
|
} else if (obj.el.type === "sideNav"){
|
|
60
60
|
return this.sideNav(obj);
|
|
61
|
-
} else if (obj.el.type === "row"){
|
|
61
|
+
} /*else if (obj.el.type === "row"){
|
|
62
62
|
return this.row(obj);
|
|
63
|
-
} else if (obj.el.type === "dropdown"){
|
|
63
|
+
} */ else if (obj.el.type === "dropdown"){
|
|
64
64
|
return this.dropdown(obj);
|
|
65
65
|
} else if (obj.el.type === "modal"){
|
|
66
66
|
return this.modal(obj);
|
|
@@ -103,7 +103,7 @@ class ElementMapper { // 22:09:58 04/11/2024
|
|
|
103
103
|
return this.stack(obj);
|
|
104
104
|
} else if (obj.el.type === "simple"){
|
|
105
105
|
return this.simple(obj);
|
|
106
|
-
}
|
|
106
|
+
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
|
|
@@ -244,29 +244,6 @@ class ElementMapper { // 22:09:58 04/11/2024
|
|
|
244
244
|
return new Slider(texts, null);//.render("#mount");
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
static table(obj){
|
|
248
|
-
return new Table()
|
|
249
|
-
.add([
|
|
250
|
-
{ abbr: "AUIUI/AK9PT", name: "Pokročilé mobilní technologie", grade: "A", date: "09.01.2024" },
|
|
251
|
-
{ abbr: "AUIUI/AK9PT", name: "Pokročilé mobilní technologie", grade: "A", date: "09.01.2024" },
|
|
252
|
-
{ abbr: "AUIUI/AK9PT", name: "Pokročilé mobilní technologie", grade: "A", date: "09.01.2024" }
|
|
253
|
-
])
|
|
254
|
-
.set({
|
|
255
|
-
cellPadding: "0.3em",
|
|
256
|
-
cellAlign: "center",
|
|
257
|
-
style: {
|
|
258
|
-
font: "Arial"
|
|
259
|
-
},
|
|
260
|
-
headStyle: {
|
|
261
|
-
color: "white",
|
|
262
|
-
background: "#ff6d22"
|
|
263
|
-
},
|
|
264
|
-
border: "2px solid black",
|
|
265
|
-
center: true,
|
|
266
|
-
borderRadius: 2.2
|
|
267
|
-
})
|
|
268
|
-
}
|
|
269
|
-
|
|
270
247
|
static dropdown(obj){
|
|
271
248
|
if (!obj.el.items){
|
|
272
249
|
obj.el.items = ["Flower", "Car", "Maseratti"];
|
|
@@ -334,9 +311,9 @@ class ElementMapper { // 22:09:58 04/11/2024
|
|
|
334
311
|
])
|
|
335
312
|
}
|
|
336
313
|
|
|
337
|
-
|
|
314
|
+
/* static row(obj){
|
|
338
315
|
const customOptions = obj.customOptions;
|
|
339
|
-
|
|
316
|
+
alert("PP")
|
|
340
317
|
let ret = new FlexRow()
|
|
341
318
|
.set({
|
|
342
319
|
borderObj: {
|
|
@@ -366,7 +343,7 @@ class ElementMapper { // 22:09:58 04/11/2024
|
|
|
366
343
|
|
|
367
344
|
return ret;
|
|
368
345
|
|
|
369
|
-
}
|
|
346
|
+
}*/
|
|
370
347
|
|
|
371
348
|
static protoNav(obj){
|
|
372
349
|
|
|
@@ -1082,6 +1059,7 @@ if (obj.el.dropdown){
|
|
|
1082
1059
|
backgroundOp: this.filtero("background", el.id, obj.customOptions),
|
|
1083
1060
|
marginOp: this.filtero("margin", el.id, obj.customOptions),
|
|
1084
1061
|
transform: this.filtero("transform", el.id, obj.customOptions),
|
|
1062
|
+
filtera: this.filtero("filter", el.id, obj.customOptions),
|
|
1085
1063
|
});
|
|
1086
1064
|
}
|
|
1087
1065
|
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
class ScrollVideo {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.frameNumber = 0; // Start video at frame 0
|
|
6
|
+
this.res = document.createElement("div");
|
|
7
|
+
this.vid = null;
|
|
8
|
+
this.minScrollHeight = 0; // Default minimum scroll height
|
|
9
|
+
this.maxScrollHeight = 1000; // Default maximum scroll height
|
|
10
|
+
this.videoUrl = ""; // Default video URL
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
set({ minScrollHeight = 0, maxScrollHeight = 1000, videoUrl = "" } = {}) {
|
|
14
|
+
this.minScrollHeight = minScrollHeight;
|
|
15
|
+
this.maxScrollHeight = maxScrollHeight;
|
|
16
|
+
this.videoUrl = videoUrl;
|
|
17
|
+
|
|
18
|
+
// Create elements after settings are provided
|
|
19
|
+
this.createElements("V0");
|
|
20
|
+
|
|
21
|
+
// Select video element after creation
|
|
22
|
+
this.vid = this.res.children[0];
|
|
23
|
+
|
|
24
|
+
// Initialize event listeners and behavior
|
|
25
|
+
this.init();
|
|
26
|
+
return this; // Allow chaining
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
createElements(videoElementId) {
|
|
30
|
+
// Create and style the video element
|
|
31
|
+
const video = document.createElement("video");
|
|
32
|
+
video.id = videoElementId;
|
|
33
|
+
video.setAttribute("tabindex", "0");
|
|
34
|
+
video.setAttribute("autobuffer", "autobuffer");
|
|
35
|
+
video.setAttribute("preload", "preload");
|
|
36
|
+
video.style.position = "sticky";
|
|
37
|
+
video.style.top = "0";
|
|
38
|
+
video.style.left = "0";
|
|
39
|
+
video.style.width = "100%";
|
|
40
|
+
video.style.height = "100vh";
|
|
41
|
+
video.style.border = "1px solid orange";
|
|
42
|
+
|
|
43
|
+
// Create and append the source element to the video
|
|
44
|
+
const source = document.createElement("source");
|
|
45
|
+
source.type = 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"';
|
|
46
|
+
source.src = this.videoUrl;
|
|
47
|
+
video.appendChild(source);
|
|
48
|
+
|
|
49
|
+
// Append the video element to the container
|
|
50
|
+
this.res.appendChild(video);
|
|
51
|
+
|
|
52
|
+
// Create and style the paragraph element
|
|
53
|
+
const paragraph = document.createElement("p");
|
|
54
|
+
paragraph.id = "time";
|
|
55
|
+
paragraph.style.fontFamily = "Helvetica, Arial, sans-serif";
|
|
56
|
+
paragraph.style.fontSize = "24px";
|
|
57
|
+
this.res.appendChild(paragraph);
|
|
58
|
+
|
|
59
|
+
// Create and style the set-height div element
|
|
60
|
+
const setHeight = document.createElement("div");
|
|
61
|
+
setHeight.id = "set-height";
|
|
62
|
+
setHeight.style.display = "block";
|
|
63
|
+
this.setop = setHeight;
|
|
64
|
+
this.res.appendChild(setHeight);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
sticky() {
|
|
68
|
+
this.res.style.position = "sticky";
|
|
69
|
+
this.res.style.top = 0;
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
init() {
|
|
74
|
+
// Set up event listener for when the video metadata is loaded
|
|
75
|
+
this.vid.addEventListener("loadedmetadata", () => {
|
|
76
|
+
// Dynamically set the page height based on video duration
|
|
77
|
+
const setHeight = this.setop;//document.getElementById("set-height");
|
|
78
|
+
if (setHeight) {
|
|
79
|
+
const scrollableHeight = this.maxScrollHeight - this.minScrollHeight;
|
|
80
|
+
setHeight.style.height = `${scrollableHeight}px`;
|
|
81
|
+
} else {
|
|
82
|
+
console.error("Error: 'set-height' element not found.");
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Start the scroll-play functionality
|
|
87
|
+
this.scrollPlay();
|
|
88
|
+
}
|
|
89
|
+
scrollPlay() {
|
|
90
|
+
// Ensure the video duration is loaded before trying to calculate currentTime
|
|
91
|
+
if (!this.vid || isNaN(this.vid.duration)) {
|
|
92
|
+
window.requestAnimationFrame(() => this.scrollPlay());
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Calculate the frame number based on scroll position
|
|
97
|
+
const scrollPosition = Math.max(
|
|
98
|
+
this.minScrollHeight,
|
|
99
|
+
Math.min(window.pageYOffset, this.maxScrollHeight)
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const scrollRange = this.maxScrollHeight - this.minScrollHeight;
|
|
103
|
+
const normalizedScroll = (scrollPosition - this.minScrollHeight) / scrollRange;
|
|
104
|
+
|
|
105
|
+
// Update the video currentTime property
|
|
106
|
+
this.vid.currentTime = normalizedScroll * this.vid.duration;
|
|
107
|
+
|
|
108
|
+
// Request the next animation frame for smooth playback
|
|
109
|
+
window.requestAnimationFrame(() => this.scrollPlay());
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
toCode() {
|
|
113
|
+
return [""];
|
|
114
|
+
}
|
|
115
|
+
render(div) {
|
|
116
|
+
if (div){
|
|
117
|
+
document.querySelector(div).appendChild(this.res);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// Return the container div with all elements
|
|
121
|
+
return this.res;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { ScrollVideo };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodality",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.21",
|
|
4
4
|
"description": "A lightweight library for declarative UI elements.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -16,9 +16,16 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "webpack --config webpack.config.js"
|
|
19
|
+
"build": "webpack --config webpack.config.js",
|
|
20
|
+
"test": "jest",
|
|
21
|
+
"postpublish": "git add . && git commit -m \"release: v$npm_package_version\" && git tag v$npm_package_version && git push --force --set-upstream origin main && git push --force origin v$npm_package_version"
|
|
22
|
+
},
|
|
23
|
+
"jest": {
|
|
24
|
+
"testEnvironment": "jsdom",
|
|
25
|
+
"transform": {
|
|
26
|
+
"^.+\\.js$": "babel-jest"
|
|
27
|
+
}
|
|
20
28
|
},
|
|
21
|
-
"dependencies": {},
|
|
22
29
|
"license": "MIT",
|
|
23
30
|
"repository": {
|
|
24
31
|
"type": "git",
|
|
@@ -35,5 +42,12 @@
|
|
|
35
42
|
"library",
|
|
36
43
|
"declarative",
|
|
37
44
|
"nodality"
|
|
38
|
-
]
|
|
45
|
+
],
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@babel/core": "^7.28.0",
|
|
48
|
+
"@babel/preset-env": "^7.28.0",
|
|
49
|
+
"babel-jest": "^29.7.0",
|
|
50
|
+
"jest": "^29.7.0",
|
|
51
|
+
"jest-environment-jsdom": "^29.7.0"
|
|
52
|
+
}
|
|
39
53
|
}
|