-
Notifications
You must be signed in to change notification settings - Fork 1
/
kult.js
722 lines (683 loc) · 21.2 KB
/
kult.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
import {gsap, ExpoScaleEase, Flip, MotionPathPlugin, RoughEase, SlowMo, SplitText} from "./scripts/external/greensock/all.js";
import U from "./scripts/utilities.js";
import C from "./scripts/constants.js";
import DEBUG from "./scripts/debug.js";
import TarotDeck from "./scripts/tarot-deck.js";
import TarotCard from "./scripts/tarot-card.js";
// #region ▮▮▮▮▮▮▮[INITIALIZATION] Initialization, Configuration & Constants ▮▮▮▮▮▮▮ ~
gsap.registerPlugin(ExpoScaleEase, Flip, MotionPathPlugin, RoughEase, SlowMo, SplitText);
gsap.config({force3D: true, nullTargetWarn: false});
gsap.registerEffect({
name: "slowRotate",
effect(targets, config) {
targets = targets.filter((target) => /rotation-container/.test(target.id));
return gsap.to(targets, {
rotationZ: config.rotationZ,
duration: config.duration,
delay: config.delay,
repeat: -1,
ease: "none",
onUpdate() {
return gsap.set(`#${targets[0].id} > .tarot-card-main`, {
rotationZ: -1 * gsap.getProperty(targets[0], "rotationZ")
});
}
});
},
defaults: {
rotationZ: "+=360",
duration: 150,
delay: 1
}
});
gsap.registerEffect({
name: "wiggleCard",
extendTimeline: true,
defaults: {
z: 20,
angle: 5,
duration: 0.2
},
effect: (targets, config = {}) => gsap.timeline()
.to(targets, {
z: config.z,
rotationX: config.angle,
rotationY: config.angle,
duration: 0.5,
repeat: 1,
yoyo: true,
ease: "circ.out"
}, 0)
.to(targets, {
rotationX: -config.angle,
repeat: 1,
yoyo: true,
duration: 0.25,
repeatDelay: 0.25,
ease: "sine.inOut"
}, 0)
.to(targets, {
rotationY: -config.angle,
repeat: 1,
yoyo: true,
duration: 0.25,
repeatDelay: 0.25,
ease: "sine.inOut"
}, 0.25)
.to(targets, {rotationX: 0, rotationY: 0, duration: 0.15, ease: "power2.out"}, ">")
.timeScale(1 / config.duration)
});
/*
- have suit or key symbol ghost-pop-expand like a pulse whenever the card spits out ghost text
- give box shadow to ghost container element and blur it a bunch, with a border radius, maybe less taxing
- ghost text should rise out of a point ON the card, same z-coord and everything, then animate it to the desired 3d position
- look at codepen and google animation examples of what you want so you can steal their ease curves and timing
*/
gsap.registerEffect({
name: "splashGhostText",
extendTimeline: true,
defaults: {
duration: 10,
ease: "none",
delay: 0,
xMult: {min: 0, max: 1.5},
yMult: {min: 0.5, max: 1}
},
effect: (targets, config = {}) => {
/* What we want to happen:
- letters start in
1) x, y, z = final relative position within container divs, but with absolute = true
2) drop-shadow filter only
3) opacity: 1
4) scale: 1
- letter-container starts at initial x pos but final z pos, doesn't start moving till letters are in place
- from(letters): (all start time = 0)
- opacity: 0 --- very fast, staggered,
- x & y: origin --- starts slow, ends fast; will have to determine origin point relative to ghost-container
- might be tricky if we want ghost container to start moving before all letters are in place
- z: origin --- starts fast, ends slow
- blur filter --- fit into either x/y or z tween
- to(letter-container): starts sometime into animation, uses back-and-forth slow ease
- to(letters) --- hop out and fade out, staggered so they're gone before letter-container animation finishes
For positioning:
function getXPos(eWidth, eMult) { return eMult * slotWidth - 0.5 * eWidth }
function getYPos(eHeight, eMult) { return eMult * slotHeight - 0.5 * eHeight }
*/
gsap.set(targets, {filter: "blur(0px) drop-shadow(20px 20px 10px black)"});
// gsap.set(targets, {filter: "blur(0px)"});
const [ghostContainer] = $(targets[0]).parents("div.ghost-container");
const containerWidth = parseInt(gsap.getProperty(ghostContainer, "width", "px"));
const containerHeight = parseInt(gsap.getProperty(ghostContainer, "height", "px"));
const timeToStaggerTargets = 0.1 * targets.length;
return gsap.timeline({delay: config.delay})
.fromTo(ghostContainer, {
x: gsap.utils.random(config.xMin * containerWidth, config.xMax * containerWidth),
y: gsap.utils.random(-0.5 * containerHeight, 0.5 * containerHeight),
z: gsap.utils.random(150, 250, 1)
}, {
x: `+=${config.xMax * containerWidth - config.xMin * containerWidth}`,
duration: config.duration + timeToStaggerTargets,
ease: "slow(0.1, 2, false)"
}, 0)
.to(ghostContainer, {
z: "+=500",
y: "-=200",
ease: "expo.in",
duration: config.duration + timeToStaggerTargets - 0.5 * (config.duration + timeToStaggerTargets)
}, 0.5 + 0.5 * (config.duration + timeToStaggerTargets))
.fromTo(targets, {
filter: "blur(20px) drop-shadow(20px 20px 10px black)",
opacity: 0
}, {
filter: "blur(0px) drop-shadow(20px 20px 10px black)",
opacity: 1,
duration: (0.2 * config.duration) / 2,
ease: config.ease,
stagger: {
amount: 0.5,
ease: "none",
from: "end"
}
}, 0)
.to(targets, {
filter: "blur(30px) drop-shadow(20px 20px 10px black)",
duration: (0.2 * config.duration) / 2,
ease: config.ease,
stagger: {
amount: 0.5,
ease: "none",
from: "end",
onComplete() {
gsap.to(this.targets()[0], {
duration: 0.1,
opacity: 0,
ease: "none",
clearProps: "filter"
});
}
}
}, config.duration - (0.2 * config.duration) / 2 + timeToStaggerTargets)
.to(targets, {
x: "+=200",
y: "-=300",
scale: 2,
duration: 3,
ease: "expo.in",
stagger: {
amount: config.duration + timeToStaggerTargets - 0.5 * (config.duration + timeToStaggerTargets),
ease: "expo.out",
from: "end"
}
}, config.duration - (0.2 * config.duration) / 2 + timeToStaggerTargets - 1)
.timeScale(gsap.utils.random(0.8, 1.2));
}
});
gsap.registerEffect({
name: "splashPopText",
extendTimeline: true,
defaults: {
duration: 5,
ease: "expo.inOut",
delay: 0
},
effect: (targets, config = {}) => {
gsap.set(targets, {filter: "blur(0px) drop-shadow(20px 20px 10px black)"});
const [popContainer] = $(targets[0]).parents("div.pop-container");
const [cardElem] = $(popContainer).parent();
const cardInst = TarotDeck.GetCard(cardElem);
const timeToStaggerTargets = (0.1 * targets.length) / 2;
return gsap.timeline({delay: config.delay, onComplete() { cardInst.isShowingPopText = false }})
.to(popContainer, {
z: "+=100",
scale: 3,
duration: config.duration + timeToStaggerTargets,
ease: "slow(0.1, 1, false)"
})
.fromTo(targets, {
filter: "blur(20px) drop-shadow(20px 20px 30px black)"
}, {
filter: "blur(0px) drop-shadow(20px 20px 10px black)",
duration: (0.2 * config.duration) / 2,
ease: config.ease,
stagger: {
amount: 0.5,
ease: "none",
start: "edges"
}
}, 0)
.from(targets, {
duration: 0.1,
opacity: 0,
ease: "none",
stagger: {
each: 0.02,
ease: "power2",
start: "center"
}
}, 0)
.to(targets, {
filter: "blur(30px) drop-shadow(20px 20px 30px black)",
duration: (0.2 * config.duration) / 2,
ease: config.ease,
stagger: {
amount: 0.5,
ease: "none",
from: "center",
onComplete() {
gsap.to(this.targets()[0], {
duration: 0.1,
opacity: 0,
ease: "none",
clearProps: "filter"
});
}
}
}, config.duration - (0.2 * config.duration) / 2 + timeToStaggerTargets - 0.5);
}
});
// gsap.registerEffect({
// name: "slowBob",
// effect: (targets, config) => {
// },
// name, effect}));
// this._bobAnim = gsap.timeline({
// paused: true,
// repeat: -1,
// yoyo: true
// })
// .to(this.deckElem, {
// z: "+=50",
// ease: "sine.out",
// duration:
// })
const SessionData = {
deck: false,
decks: [],
template: false,
_phase: C.phases.deckSelection,
inTransition: true,
get phase() {
if (this.inTransition) {
return C.phases.inTransition;
}
return this._phase;
},
set phase(v) { this._phase = v },
layout: {
1: {card: false, shiftCard: false, pos: C.slotPos[1], isFaceUp: false, ghostText: false, promptText: false},
2: {card: false, shiftCard: false, pos: C.slotPos[2], isFaceUp: false, ghostText: false, promptText: false},
3: {card: false, shiftCard: false, pos: C.slotPos[3], isFaceUp: false, ghostText: false, promptText: false},
4: {card: false, shiftCard: false, pos: C.slotPos[4], isFaceUp: false, ghostText: false, promptText: false},
5: {card: false, shiftCard: false, pos: C.slotPos[5], isFaceUp: false, ghostText: false, promptText: false}
},
ghostText: {
intervalTimer: null,
slotBins: {
1: [],
2: [],
3: [],
4: [],
5: []
},
slotQueue: [],
categories: {
individual: true,
location: true,
organization: true,
situation: true,
creature: true,
item: true
},
get next() {
const isShuffling = SessionData.ghostText.slotQueue.length === 0;
const validSlots = Object.entries(SessionData.ghostText.slotBins)
.filter(([slot, texts]) => texts.length)
.map(([slot]) => slot);
for (const slot of validSlots) {
if (!SessionData.ghostText.slotQueue.includes(slot)) {
SessionData.ghostText.slotQueue.unshift(slot);
}
}
if (SessionData.ghostText.slotQueue.length === 0) {
return false;
}
if (isShuffling) {
SessionData.ghostText.slotQueue = gsap.utils.shuffle(SessionData.ghostText.slotQueue);
}
const thisSlot = SessionData.ghostText.slotQueue.shift();
SessionData.ghostText.slotQueue.push(thisSlot);
return [thisSlot, gsap.utils.random(SessionData.ghostText.slotBins[thisSlot])];
}
},
get nextFaceDownSlot() { return [1, 2, 3, 4, 5].find((slot) => this.layout[slot].card && this.layout[slot].isFaceUp === false) },
get nextEmptySlot() { return [1, 2, 3, 4, 5].find((slot) => this.layout[slot].card === false) },
get cards() { return Object.values(this.layout).map(({card}) => card) }
};
const initGhostTextTimer = (stagger = 5, duration = 10) => {
stopGhostText();
function showNextGhostText() {
SessionData.ghostText.timer = gsap.delayedCall(stagger, showNextGhostText);
const [slot, text] = SessionData.ghostText.next || [];
if (text) {
ghostText(slot, text, duration);
}
}
showNextGhostText();
};
const stopGhostText = () => {
SessionData.ghostText.timer?.kill();
delete SessionData.ghostText.timer;
gsap.to(".ghost-text", {
opacity: 0,
duration: 0.25,
onComplete(i, elem) {
$(elem).remove();
}
});
};
function ghostPopText(text, card, yPercent, z = 0, {css = {}, vars = {}} = {}) {
card.isShowingPopText = true;
// First create the internal text element, to measure its width.
const $textElem = $("<span class=\"pop-text\"></span>")
.text(text)
.appendTo(card.cardElem);
gsap.set($textElem, {
whiteSpace: "nowrap",
...css,
textAlign: "center"
});
const textWidth = parseInt(gsap.getProperty($textElem[0], "width", "px"));
// const textHeight = parseInt(gsap.getProperty($textElem[0], "height", "px"));
// gsap.set($ghostElem, {
// backgroundColor: "rgba(255, 0, 0, 0.2)",
// outline: "1px dotted red"
// });
// Now create the container to control translation animations
const $textContainer = $(`<div class="pop-container pop-container-slot-${card.slot}"></div>`)
.append($textElem)
.appendTo(card.cardElem);
gsap.set($textContainer, {
display: "block",
xPercent: -50,
yPercent: -50,
// height: textHeight,
width: textWidth,
position: "absolute",
pointerEvents: "none",
transformOrigin: "50% 50%",
x: C.card.width / 2,
y: C.card.height * (yPercent / 100),
z,
rotationX: -25
// backgroundColor: "rgba(0, 255, 255, 0.2)",
// outline: "2px dotted cyan"
});
const split = new SplitText($textElem[0], {type: "chars,words,lines"});
gsap.effects.splashPopText(split.chars, vars).then(() => $($textContainer).remove());
}
function ghostBanner(text, vPos = "middle", css = {}) {
// First create the internal text element, to measure its width.
const [ghostElem] = $("<span class=\"ghost-text ghost-banner\"></span>")
.html(text)
.appendTo("#control-layer");
gsap.set(ghostElem, {whiteSpace: "nowrap", ...css});
const ghostWidth = parseInt(gsap.getProperty(ghostElem, "width", "px"));
const ghostHeight = parseInt(gsap.getProperty(ghostElem, "height", "px"));
// Now create the container to control translation animations
const [ghostContainer] = $("<div class=\"ghost-container ghost-banner-container\"></div>")
.append(ghostElem)
.appendTo("#control-layer");
gsap.set(ghostContainer, {
display: "blocK",
xPercent: -50,
yPercent: -50,
height: ghostHeight,
width: ghostWidth,
position: "absolute",
pointerEvents: "none",
transformOrigin: "50% 50%",
x: parseInt(gsap.getProperty("#control-layer", "width", "px")) / 2,
y: {
top: 0,
middle: parseInt(gsap.getProperty("#control-layer", "height", "px")) / 2,
bottom: parseInt(gsap.getProperty("#control-layer", "height", "px"))
}[vPos]
});
const split = new SplitText(ghostElem, {type: "chars,words,lines", position: "absolute"});
return gsap.effects.splashGhostText(split.chars, {xMin: -0.3, xMax: 0.3}).then(() => $(ghostContainer).remove());
}
function ghostText(slot, text, duration) {
// Retrieve top container for slot ghost text
const [ghostSlot] = $(`#ghost-slot-${slot}`);
const slotWidth = parseInt(gsap.getProperty(ghostSlot, "width", "px"));
const slotHeight = parseInt(gsap.getProperty(ghostSlot, "height", "px"));
// Create the internal text element, to measure its width.
const [ghostElem] = $("<span class=\"ghost-text\"></span>")
.html(text)
.appendTo(ghostSlot);
gsap.set(ghostElem, {whiteSpace: "nowrap"});
const ghostWidth = parseInt(gsap.getProperty(ghostElem, "width", "px"));
const ghostHeight = parseInt(gsap.getProperty(ghostElem, "height", "px"));
// Now create the container to control translation animations
const [ghostContainer] = $(`<div class="ghost-container ghost-container-slot-${slot}"></div>`)
.append(ghostElem)
.appendTo(ghostSlot);
gsap.set(ghostContainer, {
display: "blocK",
xPercent: -50,
yPercent: -50,
height: ghostHeight,
width: ghostWidth,
position: "absolute",
pointerEvents: "none",
transformOrigin: "50% 50%",
x: slotWidth / 2,
y: slotHeight / 2,
z: 0,
rotationX: -1 * gsap.getProperty("#over-layer", "rotationX")
});
const split = new SplitText(ghostElem, {type: "chars", position: "absolute"});
return gsap.timeline({onComplete() { $(ghostContainer).remove() }})
.splashGhostText(split.chars, {duration}, 0)
.wiggleCard(SessionData.layout[slot].card.cardElem, {z: 20, angle: 5, duration: 0.2}, 0.5);
}
const SetPhase = (phase, data) => {
phase = phase in C.phases ? C.phases[phase] : phase;
if (Object.values(C.phases).includes(phase)) {
SessionData.phase = phase;
console.log(`*** SWITCHING PHASE TO: ${phase}`);
switch (phase) {
case C.phases.deckSelection: return initDeckSelection();
case C.phases.cardsInOrbit: return initCardsOrbit(data);
case C.phases.cardsDealt: return initCardsDealt();
case C.phases.cardsRevealed: return initCardsRevealed();
default: return true;
}
}
return false;
};
const Update = () => { };
const initDeckSelection = () => {
SessionData.inTransition = true;
gsap.timeline()
.set(".deck-box .face", {opacity: 0})
.fromTo("#reading-section", {
rotationZ: 65
// y: 0
}, {
rotationZ: 0,
// y: "-15vh",
duration: 16,
ease: "back.out(2)"
}, 0)
.fromTo(".deck-box", {
z: -25
}, {
z: 25,
duration: 2,
stagger: {
each: 0.5,
from: "random",
onStart() {
gsap.to(`#${this.targets()[0].id} .face:not(.face-back)`, {
opacity: 1,
ease: "none",
duration: 3
});
}
},
onComplete() {
SessionData.inTransition = false;
ghostBanner("Which of the Tarot will guide you?", {y: C.slotPos[1].y - 100});
},
ease: "power2.out"
}, 0)
.fromTo("#reading-section", {
scale: 2
}, {
scale: 1,
duration: 16,
ease: "expoScale(2, 1, back.out(2))"
}, 0)
.to("#blackout-layer", {
opacity: 0,
duration: 0.5,
rotationX: 45,
ease: "sine",
onComplete() { $("#blackout-layer").remove() }
}, 0)
.to(".canvas-layer:not(#control-layer)", {
rotationX: 45,
duration: 10,
ease: "elastic.out(1, 0.75)" // "sine"
}, 0);
};
const initCardsOrbit = ({deck}) => {
SessionData.inTransition = true;
SessionData.deck = deck;
SessionData.deck.initMainDeck();
};
const initCardsDealt = () => {
SessionData.inTransition = true;
gsap.timeline()
.to("#reading-section", {
perspective: 1000,
y: "-=1.5vh",
duration: 7,
scale: 1
}, 0)
.to("#over-layer", {
scale: 5,
duration: 2,
ease: "power2.out",
onComplete() {
$("#over-layer > .rotation-container").remove();
gsap.set("#over-layer", {scale: 1, rotationX: 35});
}
}, 0)
.to(".canvas-layer:not(#over-layer):not(#control-layer)", {
scale: 1,
rotationX: 35,
duration: 7,
ease: "sine",
onComplete() {
SessionData.inTransition = false;
ghostBanner("The Core Card", {x: C.slotPos[2].x});
initGhostTextTimer(7, 10);
}
}, 0)
.then(() => {
for (let i = 1; i <= 5; i++) {
const $ghostZone = $(`<div id="ghost-slot-${i}" class="ghost-zone"></div>`)
.appendTo("#card-layer");
gsap.set($ghostZone, {
// xPercent: -50,
// yPercent: -50,
height: C.card.height,
width: C.card.width,
// backgroundColor: "rgba(0, 255, 0, 0.2)",
// outline: "2px dashed lime",
position: "absolute",
pointerEvents: "none",
display: "block",
x: gsap.getProperty(SessionData.layout[i].card.cardElem, "x"),
y: gsap.getProperty(SessionData.layout[i].card.cardElem, "y")
});
}
});
};
const initCardsRevealed = () => {
SessionData.inTransition = true;
gsap.timeline()
.to(".canvas-layer:not(#control-layer)", {
x: "-=30vw",
rotationX: "-=10",
ease: "back.out(2)",
duration: 3,
onComplete() {
SessionData.inTransition = false;
}
}, 0)
// .to(".ghost-zone", {
// x: "+=5vw",
// ease: "back.out(2)",
// duration: 3
// }, 0)
.to(".tarot-card-main", {
scale: 1,
duration: 0.5,
ease: "sine"
}, 0);
};
const InitializeDomElements = () => {
$(".canvas-layer *").remove();
if ($("#blackout-layer").length === 0) {
$("<div id=\"blackout-layer\"></div>").prependTo("body");
}
gsap.set("#blackout-layer, .canvas-layer", {
xPercent: -50,
yPercent: -50,
x: C.slotPos[1].x,
y: C.slotPos[1].y,
z(i, elem) {
switch (elem.id) {
case "blackout-layer": return 500;
case "background-layer": return C.layers.baseZ - 2;
case "under-layer": return C.layers.baseZ - 1;
case "card-layer": return C.layers.baseZ;
case "over-layer": return C.layers.baseZ + C.layers.vertShift;
case "control-layer": return 0;
default: return 0;
}
},
rotationX(i, elem) {
if (/control-layer/.test(elem.id)) {
return 0;
}
return 80;
},
scale: 1,
immediateRender: true
});
// Build Decks
const deckTypes = Object.keys(C.numCardBacksByType);
const decks = Object.keys(C.numCardBacksByType).map((deckType) => new TarotDeck(deckType, SessionData));
if (DEBUG.isLimitingDeckSize) {
decks.forEach((deck) => (deck._deck = deck._deck.slice(0, DEBUG.isLimitingDeckSize)));
}
const [row1, row2] = U.partition(decks, (v, k) => k <= Math.ceil(decks.length / 2) - 1);
const row1Margin = (gsap.getProperty("#card-layer", "width") - (C.card.width * row1.length) - (C.spacing.x * (row1.length - 1))) / 2;
const row2Margin = (gsap.getProperty("#card-layer", "width") - (C.card.width * row2.length) - (C.spacing.x * (row2.length - 1))) / 2;
row1.forEach((deck, i) => {
deck.x = row1Margin + (0.5 * C.card.width) + i * (C.spacing.x + C.card.width);
deck.y = Number(C.card.height);
SessionData.decks.push(deck);
deck.render(1);
});
row2.forEach((deck, i) => {
deck.x = row2Margin + (0.5 * C.card.width) + i * (C.spacing.x + C.card.width);
deck.y = 2.5 * C.card.height;
SessionData.decks.push(deck);
deck.render(2);
});
};
const Initialize = () => {
// Add invisible debug button
$("<button id=\"start-debug\"></button>")
.prependTo("#debug-layer")
.click(() => {
console.log("CLICKED!");
DEBUG.initialize();
});
gsap.set("#start-debug", {
position: "absolute",
top: 0,
left: 0,
height: 50,
width: 50,
border: "none",
outline: "none",
opacity: 0,
pointerEvents: "all"
});
// Initialize deck and card classes
TarotDeck.Initialize();
TarotCard.Initialize();
// Step One: Select Reading Template
// Step Two: Select Deck
initDeckSelection();
};
// #endregion ▮▮▮▮[INITIALIZATION]▮▮▮▮
console.clear();
InitializeDomElements();
$(document).ready(() => {
Initialize();
});
export {
InitializeDomElements,
Initialize,
SessionData,
SetPhase,
Update,
ghostPopText
};