nodality 1.0.0-beta.7 → 1.0.0-beta.71

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