nodality 1.0.0-beta.4 → 1.0.0-beta.41

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.
Files changed (278) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +108 -0
  3. package/dist/animator.cjs.js +2 -1
  4. package/dist/animator.cjs.js.LICENSE.txt +5 -0
  5. package/dist/animator.esm.js +2 -1
  6. package/dist/animator.esm.js.LICENSE.txt +5 -0
  7. package/dist/appleanim.cjs.js +2 -0
  8. package/dist/appleanim.cjs.js.LICENSE.txt +5 -0
  9. package/dist/appleanim.esm.js +2 -0
  10. package/dist/appleanim.esm.js.LICENSE.txt +5 -0
  11. package/dist/audionew.cjs.js +2 -1
  12. package/dist/audionew.cjs.js.LICENSE.txt +5 -0
  13. package/dist/audionew.esm.js +2 -1
  14. package/dist/audionew.esm.js.LICENSE.txt +5 -0
  15. package/dist/base.cjs.js +2 -1
  16. package/dist/base.cjs.js.LICENSE.txt +5 -0
  17. package/dist/base.esm.js +2 -1
  18. package/dist/base.esm.js.LICENSE.txt +5 -0
  19. package/dist/betaDesktopBar.esm.js +2 -1
  20. package/dist/betaDesktopBar.esm.js.LICENSE.txt +5 -0
  21. package/dist/betaMobileBar.esm.js +2 -1
  22. package/dist/betaMobileBar.esm.js.LICENSE.txt +5 -0
  23. package/dist/bundle.umd.js +2 -1
  24. package/dist/bundle.umd.js.LICENSE.txt +5 -0
  25. package/dist/button.cjs.js +2 -1
  26. package/dist/button.cjs.js.LICENSE.txt +5 -0
  27. package/dist/button.esm.js +2 -1
  28. package/dist/button.esm.js.LICENSE.txt +5 -0
  29. package/dist/cardGetter.cjs.js +2 -1
  30. package/dist/cardGetter.cjs.js.LICENSE.txt +5 -0
  31. package/dist/cardGetter.esm.js +2 -1
  32. package/dist/cardGetter.esm.js.LICENSE.txt +5 -0
  33. package/dist/center.cjs.js +2 -1
  34. package/dist/center.cjs.js.LICENSE.txt +5 -0
  35. package/dist/center.esm.js +2 -1
  36. package/dist/center.esm.js.LICENSE.txt +5 -0
  37. package/dist/checkbox.cjs.js +2 -1
  38. package/dist/checkbox.cjs.js.LICENSE.txt +5 -0
  39. package/dist/checkbox.esm.js +2 -1
  40. package/dist/checkbox.esm.js.LICENSE.txt +5 -0
  41. package/dist/code.cjs.js +2 -1
  42. package/dist/code.cjs.js.LICENSE.txt +5 -0
  43. package/dist/code.esm.js +2 -1
  44. package/dist/code.esm.js.LICENSE.txt +5 -0
  45. package/dist/container.cjs.js +2 -1
  46. package/dist/container.cjs.js.LICENSE.txt +5 -0
  47. package/dist/container.esm.js +2 -1
  48. package/dist/container.esm.js.LICENSE.txt +5 -0
  49. package/dist/datalist.cjs.js +2 -1
  50. package/dist/datalist.cjs.js.LICENSE.txt +5 -0
  51. package/dist/datalist.esm.js +2 -1
  52. package/dist/datalist.esm.js.LICENSE.txt +5 -0
  53. package/dist/designer.cjs.js +2 -1
  54. package/dist/designer.cjs.js.LICENSE.txt +5 -0
  55. package/dist/designer.esm.js +2 -1
  56. package/dist/designer.esm.js.LICENSE.txt +5 -0
  57. package/dist/dropdown.cjs.js +2 -1
  58. package/dist/dropdown.cjs.js.LICENSE.txt +5 -0
  59. package/dist/dropdown.esm.js +2 -1
  60. package/dist/dropdown.esm.js.LICENSE.txt +5 -0
  61. package/dist/elementMapper.cjs.js +2 -1
  62. package/dist/elementMapper.cjs.js.LICENSE.txt +5 -0
  63. package/dist/elementMapper.esm.js +2 -1
  64. package/dist/elementMapper.esm.js.LICENSE.txt +5 -0
  65. package/dist/finalresult.esm.js +2 -1
  66. package/dist/finalresult.esm.js.LICENSE.txt +5 -0
  67. package/dist/flexCard.cjs.js +2 -1
  68. package/dist/flexCard.cjs.js.LICENSE.txt +5 -0
  69. package/dist/flexCard.esm.js +2 -1
  70. package/dist/flexCard.esm.js.LICENSE.txt +5 -0
  71. package/dist/flexGrid.cjs.js +2 -1
  72. package/dist/flexGrid.cjs.js.LICENSE.txt +5 -0
  73. package/dist/flexGrid.esm.js +2 -1
  74. package/dist/flexGrid.esm.js.LICENSE.txt +5 -0
  75. package/dist/flexRow.cjs.js +2 -1
  76. package/dist/flexRow.cjs.js.LICENSE.txt +5 -0
  77. package/dist/flexRow.esm.js +2 -1
  78. package/dist/flexRow.esm.js.LICENSE.txt +5 -0
  79. package/dist/floatingInput.cjs.js +2 -1
  80. package/dist/floatingInput.cjs.js.LICENSE.txt +5 -0
  81. package/dist/floatingInput.esm.js +2 -1
  82. package/dist/floatingInput.esm.js.LICENSE.txt +5 -0
  83. package/dist/free.cjs.js +2 -1
  84. package/dist/free.cjs.js.LICENSE.txt +5 -0
  85. package/dist/free.esm.js +2 -1
  86. package/dist/free.esm.js.LICENSE.txt +5 -0
  87. package/dist/horizontalScroller.esm.js +2 -1
  88. package/dist/horizontalScroller.esm.js.LICENSE.txt +5 -0
  89. package/dist/image.cjs.js +2 -1
  90. package/dist/image.cjs.js.LICENSE.txt +5 -0
  91. package/dist/image.esm.js +2 -1
  92. package/dist/image.esm.js.LICENSE.txt +5 -0
  93. package/dist/imagePicker.cjs.js +2 -1
  94. package/dist/imagePicker.cjs.js.LICENSE.txt +5 -0
  95. package/dist/imagePicker.esm.js +2 -1
  96. package/dist/imagePicker.esm.js.LICENSE.txt +5 -0
  97. package/dist/index.cjs.js +2 -1
  98. package/dist/index.cjs.js.LICENSE.txt +5 -0
  99. package/dist/index.esm.js +2 -1
  100. package/dist/index.esm.js.LICENSE.txt +5 -0
  101. package/dist/link.cjs.js +2 -1
  102. package/dist/link.cjs.js.LICENSE.txt +5 -0
  103. package/dist/link.esm.js +2 -1
  104. package/dist/link.esm.js.LICENSE.txt +5 -0
  105. package/dist/linkGetter.cjs.js +2 -1
  106. package/dist/linkGetter.cjs.js.LICENSE.txt +5 -0
  107. package/dist/linkGetter.esm.js +2 -1
  108. package/dist/linkGetter.esm.js.LICENSE.txt +5 -0
  109. package/dist/metaAdder.cjs.js +2 -1
  110. package/dist/metaAdder.cjs.js.LICENSE.txt +5 -0
  111. package/dist/metaAdder.esm.js +2 -1
  112. package/dist/metaAdder.esm.js.LICENSE.txt +5 -0
  113. package/dist/modal2025.cjs.js +2 -1
  114. package/dist/modal2025.cjs.js.LICENSE.txt +5 -0
  115. package/dist/modal2025.esm.js +2 -1
  116. package/dist/modal2025.esm.js.LICENSE.txt +5 -0
  117. package/dist/multiswitchers.esm.js +2 -1
  118. package/dist/multiswitchers.esm.js.LICENSE.txt +5 -0
  119. package/dist/newNavBar.cjs.js +2 -1
  120. package/dist/newNavBar.cjs.js.LICENSE.txt +5 -0
  121. package/dist/newNavBar.esm.js +2 -1
  122. package/dist/newNavBar.esm.js.LICENSE.txt +5 -0
  123. package/dist/picker.cjs.js +2 -1
  124. package/dist/picker.cjs.js.LICENSE.txt +5 -0
  125. package/dist/picker.esm.js +2 -1
  126. package/dist/picker.esm.js.LICENSE.txt +5 -0
  127. package/dist/progress.cjs.js +2 -1
  128. package/dist/progress.cjs.js.LICENSE.txt +5 -0
  129. package/dist/progress.esm.js +2 -1
  130. package/dist/progress.esm.js.LICENSE.txt +5 -0
  131. package/dist/radio.cjs.js +2 -1
  132. package/dist/radio.cjs.js.LICENSE.txt +5 -0
  133. package/dist/radio.esm.js +2 -1
  134. package/dist/radio.esm.js.LICENSE.txt +5 -0
  135. package/dist/range.cjs.js +2 -1
  136. package/dist/range.cjs.js.LICENSE.txt +5 -0
  137. package/dist/range.esm.js +2 -1
  138. package/dist/range.esm.js.LICENSE.txt +5 -0
  139. package/dist/scrollvideo.cjs.js +2 -0
  140. package/dist/scrollvideo.cjs.js.LICENSE.txt +5 -0
  141. package/dist/scrollvideo.esm.js +2 -0
  142. package/dist/scrollvideo.esm.js.LICENSE.txt +5 -0
  143. package/dist/sideBar.cjs.js +2 -1
  144. package/dist/sideBar.cjs.js.LICENSE.txt +5 -0
  145. package/dist/sideBar.esm.js +2 -1
  146. package/dist/sideBar.esm.js.LICENSE.txt +5 -0
  147. package/dist/sideNavBar.cjs.js +2 -1
  148. package/dist/sideNavBar.cjs.js.LICENSE.txt +5 -0
  149. package/dist/sideNavBar.esm.js +2 -1
  150. package/dist/sideNavBar.esm.js.LICENSE.txt +5 -0
  151. package/dist/simpleBar.cjs.js +2 -1
  152. package/dist/simpleBar.cjs.js.LICENSE.txt +5 -0
  153. package/dist/simpleBar.esm.js +2 -1
  154. package/dist/simpleBar.esm.js.LICENSE.txt +5 -0
  155. package/dist/stack.cjs.js +2 -1
  156. package/dist/stack.cjs.js.LICENSE.txt +5 -0
  157. package/dist/stack.esm.js +2 -1
  158. package/dist/stack.esm.js.LICENSE.txt +5 -0
  159. package/dist/stacker.cjs.js +2 -0
  160. package/dist/stacker.cjs.js.LICENSE.txt +5 -0
  161. package/dist/stacker.esm.js +2 -0
  162. package/dist/stacker.esm.js.LICENSE.txt +5 -0
  163. package/dist/table.cjs.js +2 -1
  164. package/dist/table.cjs.js.LICENSE.txt +5 -0
  165. package/dist/table.esm.js +2 -1
  166. package/dist/table.esm.js.LICENSE.txt +5 -0
  167. package/dist/text.cjs.js +2 -1
  168. package/dist/text.cjs.js.LICENSE.txt +5 -0
  169. package/dist/text.esm.js +2 -1
  170. package/dist/text.esm.js.LICENSE.txt +5 -0
  171. package/dist/textField.cjs.js +2 -1
  172. package/dist/textField.cjs.js.LICENSE.txt +5 -0
  173. package/dist/textField.esm.js +2 -1
  174. package/dist/textField.esm.js.LICENSE.txt +5 -0
  175. package/dist/transformanim.cjs.js +2 -0
  176. package/dist/transformanim.cjs.js.LICENSE.txt +5 -0
  177. package/dist/transformanim.esm.js +2 -0
  178. package/dist/transformanim.esm.js.LICENSE.txt +5 -0
  179. package/dist/wrap.cjs.js +2 -1
  180. package/dist/wrap.cjs.js.LICENSE.txt +5 -0
  181. package/dist/wrap.esm.js +2 -1
  182. package/dist/wrap.esm.js.LICENSE.txt +5 -0
  183. package/dist/zoomCard.cjs.js +2 -1
  184. package/dist/zoomCard.cjs.js.LICENSE.txt +5 -0
  185. package/dist/zoomCard.esm.js +2 -1
  186. package/dist/zoomCard.esm.js.LICENSE.txt +5 -0
  187. package/layout/DEPRECATED-PARAGRAPH.js +6 -0
  188. package/layout/animator.js +6 -0
  189. package/layout/audio.js +6 -0
  190. package/layout/audionew.js +6 -0
  191. package/layout/base-2.js +6 -0
  192. package/layout/base.js +6 -0
  193. package/layout/betaDesktopBar.js +6 -0
  194. package/layout/betaMobileBar.js +6 -0
  195. package/layout/box.js +6 -0
  196. package/layout/button.js +6 -0
  197. package/layout/cards.js +6 -0
  198. package/layout/center.js +6 -0
  199. package/layout/checkbox.js +6 -0
  200. package/layout/cleanRow.js +6 -0
  201. package/layout/code.js +6 -0
  202. package/layout/container.js +6 -0
  203. package/layout/custom.js +6 -0
  204. package/layout/divImage.js +6 -0
  205. package/layout/dropdown.js +6 -0
  206. package/layout/dropdown2025.js +6 -0
  207. package/layout/emptyElement.js +6 -0
  208. package/layout/externalStylesheet.js +6 -0
  209. package/layout/flexCard.js +6 -0
  210. package/layout/flexGrid.js +6 -0
  211. package/layout/flexrow.js +6 -0
  212. package/layout/footer.js +6 -0
  213. package/layout/formComponents/custom.js +6 -0
  214. package/layout/formComponents/dataList.js +6 -0
  215. package/layout/formComponents/floatingInput.js +6 -0
  216. package/layout/formComponents/form-all.js +6 -0
  217. package/layout/formComponents/form.js +6 -0
  218. package/layout/formComponents/imagePicker.js +6 -0
  219. package/layout/formComponents/picker.js +6 -0
  220. package/layout/formComponents/radio.js +6 -0
  221. package/layout/formComponents/radiogroup.js +6 -0
  222. package/layout/formComponents/range.js +6 -0
  223. package/layout/free.js +6 -0
  224. package/layout/grid-new.js +6 -0
  225. package/layout/grid.js +6 -0
  226. package/layout/gridSwitcher.js +6 -0
  227. package/layout/group.js +6 -0
  228. package/layout/header.js +6 -0
  229. package/layout/horizontalScroller.js +6 -0
  230. package/layout/image-old.js +6 -0
  231. package/layout/image.js +6 -0
  232. package/layout/index.js +22 -0
  233. package/layout/label.js +6 -0
  234. package/layout/link.js +6 -0
  235. package/layout/list-OLD.js +6 -0
  236. package/layout/list.js +6 -0
  237. package/layout/metaAdder.js +6 -0
  238. package/layout/modal2025.js +6 -0
  239. package/layout/modernwrap.js +6 -0
  240. package/layout/multiswitcher.js +6 -0
  241. package/layout/multiswitcherBeta.js +6 -0
  242. package/layout/navBar-OLD.js +6 -0
  243. package/layout/navBar.js +6 -0
  244. package/layout/navFactor/customDiv.js +6 -0
  245. package/layout/newFlatAdder.js +6 -0
  246. package/layout/newNavBar copy 2.js +6 -0
  247. package/layout/newNavBar copy.js +6 -0
  248. package/layout/newNavBar.js +6 -0
  249. package/layout/offsetContainer.js +6 -0
  250. package/layout/progress.js +6 -0
  251. package/layout/row.js +6 -0
  252. package/layout/savedNewNavBar.js +6 -0
  253. package/layout/scrollvideo.js +6 -0
  254. package/layout/sideBar.js +6 -0
  255. package/layout/sideNavBar.js +7 -1
  256. package/layout/simpleBar.js +6 -0
  257. package/layout/slider2025.js +6 -0
  258. package/layout/spacer.js +6 -0
  259. package/layout/stack.js +6 -0
  260. package/layout/styler.js +6 -0
  261. package/layout/switcher.js +6 -0
  262. package/layout/table.js +6 -0
  263. package/layout/text.js +9 -1
  264. package/layout/textField.js +6 -0
  265. package/layout/ulist.js +6 -0
  266. package/layout/video.js +6 -0
  267. package/layout/withoutNew.js +6 -0
  268. package/layout/wrap.js +6 -0
  269. package/layout/zoomCard.js +6 -0
  270. package/lib/AppleAnim.js +795 -0
  271. package/lib/Stacker.js +42 -0
  272. package/lib/TransformAnim.js +520 -0
  273. package/lib/cardGetter.js +6 -0
  274. package/lib/designer.js +241 -14
  275. package/lib/elementMapper.js +15 -31
  276. package/lib/linkGetter.js +6 -0
  277. package/lib/scrollvideo.js +131 -0
  278. package/package.json +23 -4
@@ -0,0 +1,795 @@
1
+ /*!
2
+ * nodality v1.0.0-beta.41
3
+ * (c) 2025 Filip Vabrousek
4
+ * License: MIT
5
+ */
6
+
7
+
8
+ class KeyframeAnim {
9
+ constructor(data) {
10
+ this.fromFirstImageFlag = false;
11
+ this.flag = 0;
12
+ this.flagValue = data.flagValue;
13
+ this.data = data;
14
+ this.mask = data.mask; // overwrites method
15
+ this.maskData = data.maskData;
16
+ this.id = data.id;
17
+
18
+ this.halfHeight = data.halfHeight;
19
+ if (this.data.type === undefined){
20
+ this.type = "default";
21
+ } else {
22
+ this.type = this.data.type;
23
+ }
24
+
25
+ this.stickData = data.stickData;
26
+ this.targetHeight = this.data.targetHeight;
27
+ this.html = document.body;
28
+ this.res = document.createElement("div"); // stack
29
+ this.res.setAttribute("id", this.data.id);
30
+ this.res.style.border = "1px solid green";
31
+ this.res.style.width = "100%";
32
+ this.res.style.display = "grid";
33
+
34
+ //
35
+ this.res.style.position = "sticky";// removed
36
+ this.res.style.top = 0;
37
+ this.res.style.alignSelf = "flex-start";
38
+
39
+ this.res.style.justifyContent = "center";
40
+ this.res.style.alignItems = "center";
41
+
42
+
43
+ // Added
44
+
45
+
46
+ if (!this.data.added){ // Nice effect with false
47
+ this.res.style.marginTop = this.data.noAddedDistance; //"800px";
48
+ }
49
+
50
+
51
+ this.frameCount = 100; // 100
52
+
53
+
54
+
55
+
56
+
57
+ this.lastScrollTop = window.scrollY;
58
+ // modrý a bez kroužku
59
+ this.setupTopElement();
60
+ this.scrollFunction();
61
+
62
+
63
+
64
+ window.addEventListener('scroll', () => {
65
+ this.scrollFunction();
66
+ });
67
+
68
+ this.preloadImages();
69
+ return this;
70
+ }
71
+
72
+
73
+ marginTop(data){
74
+ // this.data.noAddedDistance = data;
75
+ this.res.style.marginTop = data;
76
+ return this;
77
+ }
78
+
79
+ toCode(){
80
+ return [""];
81
+ }
82
+
83
+ scrollFunction = () => {
84
+ // alert(this.flagValue);
85
+
86
+ // console.log(this.flagValue);
87
+
88
+ if (this.flagValue === undefined){
89
+ this.flagValue = 0;
90
+ }
91
+
92
+ var scrollTop = this.html.scrollTop - /*1700*/ this.flagValue;
93
+ var maxScrollTop = this.html.scrollHeight - window.innerHeight;
94
+
95
+ const scrollFraction = scrollTop / maxScrollTop * 16 /** 16*/ ; // TIMES 5 Speeds up the animation
96
+ var frameIndex = Math.min(
97
+ this.frameCount - 1,
98
+ Math.ceil(scrollFraction * this.frameCount)
99
+ );
100
+
101
+ /* if (frameIndex === 99) {
102
+ frameIndex -= 99;
103
+ }*/
104
+
105
+ if (isNaN(frameIndex)) {
106
+ frameIndex = 1;
107
+ }
108
+
109
+ if (frameIndex < 0){
110
+ frameIndex = 0;
111
+ }
112
+
113
+ // console.log(frameIndex);
114
+
115
+ if (this.data.limit){
116
+
117
+ if (frameIndex < this.data.limit){
118
+ // console.log(frameIndex)
119
+ // console.log("MY Frame index is" + frameIndex);
120
+ requestAnimationFrame(() => this.updateImage(frameIndex + 1));
121
+ }
122
+ } else {
123
+ requestAnimationFrame(() => this.updateImage(frameIndex + 1));
124
+ }
125
+
126
+
127
+ let query = window.matchMedia("(max-device-width: 415px)");
128
+
129
+
130
+ // Apple website does not transition...
131
+ /* if (query.matches === false){
132
+ if (window.scrollY > 2300){
133
+ this.res.style.position = "relative";
134
+ this.res.style.marginTop = "1300px";
135
+ } else {
136
+ this.res.style.marginTop = "800px";
137
+ this.res.style.position = "sticky";
138
+ }
139
+ }*/
140
+
141
+ // scroll less than 2300 and fix next
142
+
143
+ /* if (window.scrollY > 2300){
144
+ this.res.style.position = "relative";
145
+ this.res.style.marginTop = "1400px";
146
+ } else {
147
+ this.res.style.marginTop = "800px";
148
+ this.res.style.position = "sticky";
149
+ }*/
150
+ }
151
+
152
+
153
+ currentFrame = index => {
154
+ // https://stackoverflow.com/questions/5417979/batch-rename-sequential-files-by-padding-with-zeroes Thanks !
155
+ // for f in *.jpg;do n=${f#*_};n=${n%.*};mv $f $(printf "%04d".jpg $n);done
156
+ let res = `${this.data.path}${index.toString().padStart(4, '0')}.${this.data.extension}`;
157
+ return res;
158
+ }
159
+
160
+ preloadImages = () => {
161
+ for (let i = 1; i < this.frameCount; i++) {
162
+ const img = new Image();
163
+ this.img.src = this.currentFrame(i);
164
+ }
165
+ };
166
+
167
+ updateImage = index => {
168
+ // console.log(index);
169
+
170
+ this.img.src = this.currentFrame(index);
171
+
172
+ /* if (window.scrollY > 20 && index > 98){
173
+ this.res.style.position = "relative";
174
+ this.res.style.marginTop = "420px";
175
+ } */
176
+
177
+ /* if (window.scrollY < 620 && this.isUp){ // 163408 okay, get exact value
178
+ this.res.style.position = "fixed";
179
+ this.res.style.marginTop = "0px";
180
+ }*/
181
+
182
+
183
+ // WILL NOT WORK
184
+ /* if (window.scrollY > 1370 && !this.isUp){
185
+ this.res.style.position = "fixed";
186
+ this.res.style.marginTop = "0px";
187
+ } // 17:12:25 08/10/23 afetr win UH nice!
188
+
189
+
190
+
191
+ if (window.scrollY <= 1370 && this.isUp){
192
+ this.res.style.position = "relative";
193
+ this.res.style.marginTop = "800px";
194
+ } // 21:55:43 Nice !!!
195
+ */
196
+ // 22:20:50 developer tools change the necessary window.scrollY value
197
+ }
198
+
199
+
200
+
201
+
202
+
203
+ drawImageProp(ctx, img, x, y, w, h, offsetX, offsetY) {
204
+
205
+ if (arguments.length === 2) {
206
+ x = y = 0;
207
+ w = ctx.canvas.width;
208
+ h = ctx.canvas.height;
209
+ }
210
+
211
+ // default offset is center
212
+ offsetX = typeof offsetX === "number" ? offsetX : 0.5;
213
+ offsetY = typeof offsetY === "number" ? offsetY : 0.5;
214
+
215
+ // keep bounds [0.0, 1.0]
216
+ if (offsetX < 0) offsetX = 0;
217
+ if (offsetY < 0) offsetY = 0;
218
+ if (offsetX > 1) offsetX = 1;
219
+ if (offsetY > 1) offsetY = 1;
220
+
221
+ var iw = img.width,
222
+ ih = img.height,
223
+ r = Math.min(w / iw, h / ih),
224
+ nw = iw * r, // new prop. width
225
+ nh = ih * r, // new prop. height
226
+ cx, cy, cw, ch, ar = 1;
227
+
228
+ // decide which gap to fill
229
+ if (nw < w) ar = w / nw;
230
+ if (Math.abs(ar - 1) < 1e-14 && nh < h) ar = h / nh; // updated
231
+ nw *= ar;
232
+ nh *= ar;
233
+
234
+ // calc source rectangle
235
+ cw = iw / (nw / w);
236
+ ch = ih / (nh / h);
237
+
238
+ cx = (iw - cw) * offsetX;
239
+ cy = (ih - ch) * offsetY;
240
+
241
+ // make sure source rectangle is valid
242
+ if (cx < 0) cx = 0;
243
+ if (cy < 0) cy = 0;
244
+ if (cw > iw) cw = iw;
245
+ if (ch > ih) ch = ih;
246
+
247
+ console.log("WEIRD")
248
+ console.log(img);
249
+ console.log(cy);
250
+ console.log(cw);
251
+ // fill image in dest. rectangle
252
+ ctx.drawImage(img, cx, cy, cw, ch, x, y, w, h);
253
+ }
254
+
255
+
256
+ maska(data){
257
+ window.addEventListener("scroll", () => {
258
+ this.innerMask(data);
259
+ });
260
+
261
+ return this;
262
+ }
263
+
264
+ innerMask(data) {
265
+ if (data) {
266
+ let smart = smartRange(window.scrollY, { min: data.start, max: data.end }, { min: 0, max: 7 }) // The other way
267
+ let radius = smartRange(window.scrollY, { min: data.start, max: data.end }, { min: 37, max: 37 }) // both are 20 to stay round
268
+ this.res.style.clipPath = `inset(${smart}% ${smart}% round 0 0 ${radius}px ${radius}px)`;
269
+ }
270
+ }
271
+
272
+ setupTopElement() {
273
+ // If we scroll further after seeing topElement
274
+ console.warn("TOP INIT");
275
+
276
+
277
+
278
+ // 1 - Set up the stack
279
+ // 2 - Set up bottom elements
280
+ let fixTop = document.createElement("canvas");
281
+
282
+ fixTop.style.gridArea = "1/1";
283
+ fixTop.zIndex = 1;
284
+ fixTop.style.display = "grid";
285
+ fixTop.style.gridTemplate = "1fr/1fr";
286
+ fixTop.style.justifyContent = "center";
287
+ fixTop.style.alignItems = "center";
288
+ fixTop.style.marginLeft = "auto";
289
+ fixTop.style.marginRight = "auto";
290
+ // fixTop.style.width = "100%";
291
+
292
+
293
+ this.context = fixTop.getContext("2d");
294
+
295
+ // 1158; WAS GOOD
296
+ this.context.canvas.width = window.innerWidth; //document.body.clientWidth; // Make this responsive
297
+ this.context.canvas.height = window.innerHeight * 1.2; //window.innerWidth / 1.77778;
298
+
299
+
300
+
301
+
302
+ this.img = new Image();
303
+
304
+ this.img.onload = () => {
305
+ if (this.data.halfHeight){
306
+ this.drawImageProp(this.context, this.img, 0, 0, window.innerWidth, window.innerHeight / 2);
307
+ } else {
308
+ this.drawImageProp(this.context, this.img, 0, 0, window.innerWidth, window.innerHeight * 1.2);
309
+ }
310
+ }
311
+
312
+
313
+ // 11:41:33 Nice!
314
+ // 17/10/2023
315
+ // M2 iPad Air and iPad (11th gen) are coming today!
316
+ window.addEventListener("resize", () => {
317
+ this.context.canvas.width = window.innerWidth; //document.body.clientWidth; // Make this responsive
318
+ this.context.canvas.height = window.innerHeight * 1.2; //window.innerWidth / 1.77778;
319
+ this.drawImageProp(this.context, this.img, 0, 0, window.innerWidth, window.innerHeight * 1.2);
320
+ });
321
+
322
+ // https://twitter.com/L0vetodream/status/1240753794037600256
323
+
324
+ // git reflog 180427 git reset HEAD@{index}
325
+ this.res.appendChild(fixTop);
326
+ if (this.data.text) {
327
+ let wrap = document.createElement("div");
328
+ wrap.style.gridArea = "1/1";
329
+
330
+ let el = this.data.text.render();
331
+ this.h2a = el;
332
+ wrap.appendChild(el);
333
+ wrap.setAttribute("id", "rem");
334
+
335
+
336
+
337
+
338
+
339
+ if (this.data.hasRect) {
340
+ let e = document.createElement("div");
341
+ e.style.width = "30px";
342
+ e.style.height = "30px";
343
+ e.style.backgroundColor = "orange";
344
+ } else {
345
+ for (var i = 0; i < this.res.children.length; i++) {
346
+ if (this.res.children[i].id === "rem") {
347
+ this.res.removeChild(this.res.children[i]);
348
+ }
349
+
350
+ }
351
+ }
352
+
353
+ this.res.appendChild(wrap);
354
+ }
355
+
356
+ this.lastScrollTop = 0;
357
+ this.count = 1;
358
+ this.isUp = false;
359
+ this.done = false;
360
+ this.fireOnce = true;
361
+ this.dec = 1.0;
362
+ this.tdec = 1.0;
363
+ this.atdec = 0.0;
364
+ this.textOpacity = 1.0;
365
+
366
+ let hTwo = this.res.children[this.res.children.length - 1].children[0];
367
+ // hTwo.opacity = 0;
368
+ hTwo.style.opacity = 0;
369
+
370
+
371
+
372
+
373
+ if (this.data.text){
374
+
375
+
376
+ window.addEventListener("scroll", () => {
377
+ this.h2a.style.backgroundColor = "rgba(0, 0, 0, 0.8)"; //"black";
378
+ this.h2a.style.opacity = 1;
379
+
380
+
381
+ /* let offset = smartRange(window.scrollY, {
382
+ // min: this.data.lazyText.start,
383
+ // max: this.data.lazyText.end
384
+ min: 6180,
385
+ max: 8000
386
+ }, {
387
+ min: 0,
388
+ max: 200
389
+ }); // 175
390
+
391
+
392
+ let opacity = smartRange(window.scrollY, {
393
+ // min: this.data.lazyText.start,
394
+ // max: this.data.lazyText.end
395
+ min: 6180, // variable args
396
+ max: 8000
397
+ }, {
398
+ min: 0,
399
+ max: 1
400
+ }); // 175
401
+ */
402
+ // div below #rem has opacity 0
403
+
404
+
405
+ /* for (var i = 0; i < this.h2a.children[0].children.length; i++){
406
+ console.log("P")
407
+ this.h2a.children[0].children[i].style.transform = `matrix(1, 0, 0, 1, 0, -${offset})`;
408
+ this.h2a.children[0].children[i].style.opacity = `${opacity - i * 0.2}`;
409
+ }*/
410
+
411
+ // this.h2a.style.transform = "matrix("
412
+ // transform: matrix(1, 0, 0, 1, 0, 15.2135);
413
+
414
+
415
+ /* let offset = smartRange(window.scrollY, {
416
+ min: 3750,
417
+ max: 4000
418
+ }, {
419
+ min: 0,
420
+ max: 200
421
+ }); // 175
422
+
423
+
424
+ let opacity = smartRange(window.scrollY, {
425
+ min: 3750,
426
+ max: 4200
427
+ }, {
428
+ min: 0,
429
+ max: 1
430
+ }); // 175
431
+
432
+
433
+
434
+
435
+ for (var i = 0; i < this.h2a.children[0].children.length; i++){
436
+ this.h2a.children[0].children[i].style.transform = `matrix(1, 0, 0, 1, 0, -${offset})`;
437
+ this.h2a.children[0].children[i].style.opacity = `${opacity - i * 0.2}`;
438
+ }*/
439
+ // this.h2a.children[0].children[1].style.backgroundColor = "orange";
440
+
441
+ // this.h2a.children[0].style.transform = `matrix(1, 0, 0, 1, 0, -${offset})`;
442
+
443
+ // height here
444
+ // 1800-2200
445
+
446
+ /* let res = smartRange(window.scrollY, {
447
+ // min: 1800,
448
+ // max: 2200
449
+ // min: 30,
450
+ // max: 800
451
+
452
+ min: this.data.opacityRange.start,
453
+ max: this.data.opacityRange.end
454
+ }, {
455
+ min: 0,
456
+ max: 1
457
+ }); // 175*/
458
+
459
+ // console.log(res);
460
+
461
+
462
+
463
+
464
+
465
+ // this.h2a.style.opacity = res;
466
+ });
467
+ }
468
+
469
+
470
+
471
+
472
+
473
+
474
+
475
+ window.addEventListener("scroll", (e) => {
476
+
477
+
478
+ // newly added
479
+ if (this.data.stickyData){
480
+ if (this.data.stickyData.top){
481
+ const top = this.data.stickyData.top; //800;
482
+
483
+
484
+ // UNCOMMENT HERE
485
+
486
+ // alert(wrapDiv);
487
+ if (this.data.uncomment) {
488
+ if (window.scrollY > top) { // MAKE THIS ADJUSTABLE
489
+ wrapDiv.style.background = "pink";
490
+ wrapDiv.style.position = "relative";
491
+ wrapDiv.style.top = top; // FIX HERE
492
+ } else {
493
+ wrapDiv.style.background = "orange";
494
+ wrapDiv.style.top = 0;
495
+ wrapDiv.style.position = "fixed";
496
+ }
497
+ }
498
+ }
499
+
500
+ }
501
+
502
+
503
+ // console.log(window.scrollY);
504
+
505
+ let st = window.scrollY || document.documentElement.scrollTop;
506
+ if (st > this.lastScrollTop) {
507
+ this.isUp = false;
508
+ } else {
509
+ this.isUp = true;
510
+ }
511
+
512
+ this.lastScrollTop = st <= 0 ? 0 : st; // For Mobile or negative scrolling
513
+
514
+ if (this.isUp) {
515
+ if (this.textOpacity < 0.98) {
516
+ this.textOpacity += 0.01;
517
+ }
518
+ }
519
+
520
+ if (this.isUp === false) {
521
+ if (this.textOpacity > 0.02) {
522
+ this.textOpacity -= 0.01;
523
+ }
524
+ }
525
+
526
+ if (this.data.mask){
527
+
528
+ let rem = this.res; //document.querySelector("#beauty");
529
+
530
+ let smart = smartRange(window.scrollY, {/*min: 2189, max: 2900*/ min: this.data.maskData.start, max: this.data.maskData.end}, {min: 0, max: 7} )
531
+ rem.style.clipPath = `inset(${smart}% ${smart}% round 20px)`;
532
+ // console.log(`SMART: ${smart}`);
533
+ // console.log(this.textOpacity);
534
+
535
+
536
+ if (!this.hasH2){
537
+ let grayBack = document.createElement("div");
538
+ grayBack.style.background = "#ecf0f1";
539
+ grayBack.style.width = "86%";
540
+ grayBack.style.marginLeft = "7%";
541
+ grayBack.style.borderRadius = "1rem";
542
+
543
+ this.hasH2 = true;
544
+ grayBack.appendChild(this.data.newSection.render());
545
+ rem.parentElement.appendChild(grayBack);
546
+ }
547
+ }
548
+
549
+ // 22:09:11 Code design object
550
+ let elHeight = this.data.targetHeight;
551
+ let begin = elHeight - 250;
552
+ let end = elHeight + 250;
553
+
554
+ /* let res = sm(st + begin, {
555
+ min: begin,
556
+ max: end
557
+ }, {
558
+ min: 0,
559
+ max: 2
560
+ }); // 175
561
+
562
+ if (res < -0.3) {
563
+ res = Math.abs(res);
564
+ }
565
+
566
+ if (this.data.animation != "float") {
567
+ hTwo.style.opacity = `${res}`;
568
+ }*/
569
+
570
+
571
+ });
572
+ }
573
+
574
+
575
+
576
+
577
+ setLazyText(obj){
578
+ this.lazyText= obj;
579
+
580
+
581
+ window.addEventListener("scroll", () => {
582
+ let offset = smartRange(window.scrollY, {
583
+ min: this.lazyText.start,
584
+ max: this.lazyText.end
585
+ // min: 6180,
586
+ // max: 8000
587
+ }, {
588
+ min: 0,
589
+ max: 200
590
+ }); // 175
591
+
592
+
593
+ let opacity = smartRange(window.scrollY, {
594
+ min: this.lazyText.start,
595
+ max: this.lazyText.end
596
+ // min: 6180, // variable args
597
+ // max: 8000
598
+ }, {
599
+ min: 0,
600
+ max: 1
601
+ }); // 175
602
+
603
+ // div below #rem has opacity 0
604
+
605
+
606
+ for (var i = 0; i < this.h2a.children[0].children.length; i++){
607
+ console.log("P")
608
+ this.h2a.children[0].children[i].style.transform = `matrix(1, 0, 0, 1, 0, -${offset})`;
609
+ this.h2a.children[0].children[i].style.opacity = `${opacity - i * 0.2}`;
610
+ }
611
+
612
+ });
613
+
614
+
615
+ return this;
616
+ }
617
+
618
+ setProps(obj){
619
+
620
+ if (obj.targetHeight){
621
+ this.data.targetHeight = obj.targetHeight;
622
+ }
623
+
624
+
625
+ if (obj.flagValue){
626
+ // alert(obj.flagValue);
627
+ this.flagValue = obj.flagValue;
628
+ }
629
+
630
+ return this;
631
+ /* targetHeight: 600,
632
+ flagValue: 3700,*/
633
+ }
634
+
635
+
636
+ fixedToRelative(value){
637
+ this.data.uncomment = value;
638
+ }
639
+
640
+ toSticky(){
641
+ this.res.style.position = "sticky";
642
+ this.res.style.top = "0";
643
+ return this;
644
+ }
645
+
646
+ setOpacityRange(range){
647
+ this.data.opacityRange = range.opacityRange;
648
+ this.data.scaleRange = range.scaleRange;
649
+ // 1800 and 2200 scale
650
+
651
+
652
+ window.addEventListener("scroll", () => {
653
+ let res = smartRange(window.scrollY, {
654
+ // min: 1800,
655
+ // max: 2200
656
+ // min: 30,
657
+ // max: 800
658
+
659
+ min: this.data.opacityRange.start,
660
+ max: this.data.opacityRange.end
661
+ }, {
662
+ min: 0,
663
+ max: 1
664
+ }); // 175
665
+
666
+
667
+ this.h2a.style.opacity = res;
668
+
669
+
670
+ let scale = smartRange(window.scrollY, {
671
+ min: this.data.scaleRange.start,
672
+ max: this.data.scaleRange.end,
673
+ }, {
674
+ min: 3,
675
+ max: 1
676
+ }); // 175
677
+
678
+ /* let scaleChip = smartRange(window.scrollY, {
679
+ min: 1800,
680
+ max: 2200
681
+ }, {
682
+ min: 3,
683
+ max: 0.6
684
+ }); // 175
685
+ */
686
+ // Bad on mobile
687
+
688
+
689
+ // 00:29:51
690
+ if (!window.matchMedia("(max-device-width: 415px)").matches){
691
+ this.h2a.children[0].style.transform = `scale(${scale})`;
692
+ }
693
+
694
+ });
695
+
696
+ return this;
697
+
698
+ }
699
+
700
+
701
+
702
+ /*
703
+ stick(value){
704
+
705
+
706
+ if (topOffset != undefined){
707
+
708
+ }
709
+
710
+ if (value){
711
+ this.makeSticky();
712
+ } else {
713
+ this.noSticky();
714
+ }
715
+ return this;
716
+ }*/
717
+
718
+ stick(obj){
719
+ if (!obj){
720
+ this.makeSticky();
721
+ return this;
722
+ }
723
+
724
+
725
+ if (obj.offset){
726
+ if (this.data.stickyData != undefined){
727
+ // alert(topOffset);
728
+ this.data.stickyData.top = obj.offset;
729
+ } else {
730
+ this.data.stickyData = {top: obj.offset};
731
+
732
+ }
733
+ }
734
+
735
+ if (obj.value){
736
+ this.makeSticky();
737
+ } else {
738
+ this.noSticky();
739
+ }
740
+
741
+ return this;
742
+ }
743
+
744
+ to100vh(){
745
+ this.res.style.height = "100vh";
746
+ }
747
+
748
+
749
+ makeSticky(){
750
+ this.res.style.position = "sticky";
751
+ this.res.style.top = 0;
752
+
753
+ // 22:23:18 Yes!!!
754
+ // 22:23:39 mobile
755
+ //this.wrdiv.style.marginTop = "800px";
756
+ return this;
757
+ }
758
+
759
+
760
+ noSticky(){
761
+ // this.wrdiv.style.display = "none";
762
+ // this.wrdiv.style.filter = "grayscale(1)";
763
+ this.res.style.position = "";
764
+ return this;
765
+ }
766
+
767
+
768
+ toOpacity(opacity){
769
+ this.res.style.opacity = `${opacity}`;
770
+ }
771
+
772
+
773
+ render(id) {
774
+ // this.res.style.position = "fixed";
775
+ if (id) {
776
+ document.querySelector(id).appendChild(this.res);
777
+ } else {
778
+
779
+
780
+ // Move this out to wrapper Layout element
781
+ /* let el = document.createElement("div");
782
+ el.style.height = "2300px";
783
+ this.res.style.height = "100vh";
784
+ el.appendChild(this.res);*/
785
+
786
+ return this.res;
787
+ }
788
+
789
+ }
790
+ }
791
+
792
+
793
+ export {KeyframeAnim};
794
+
795
+ // http://localhost:64595/designertest/5-CleanScrollAnimation/cleaner-way