@zyzgroup/core-web 0.0.19 → 0.0.20

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.
@@ -27146,6 +27146,8 @@ class oT {
27146
27146
  }
27147
27147
  function Xe(r) {
27148
27148
  switch (r) {
27149
+ case "linear":
27150
+ return [0, 0, 1, 1];
27149
27151
  case "ease":
27150
27152
  return [0.25, 0.1, 0.25, 1];
27151
27153
  case "ease-in":
@@ -27167,56 +27169,37 @@ class lT {
27167
27169
  this.objects.push({
27168
27170
  width: parseFloat(i.css("width")),
27169
27171
  height: parseFloat(i.css("height")),
27170
- dom: i
27172
+ dom: i,
27173
+ el: t,
27174
+ originCSSObject: i.css()
27175
+ }), t.addEventListener("transitionend", (s) => {
27176
+ console.log("transitionend", s);
27171
27177
  });
27172
27178
  }), this;
27173
27179
  }
27174
27180
  toCSS(e, ...t) {
27175
- switch (this[e](...t), this.objects[0].dom?.parent().css({ position: "relative", perspective: "1000px", overflow: "hidden" }), e) {
27181
+ switch (this["_" + e](...t), this.objects[0].dom?.parent().css({ position: "relative", perspective: "1000px", overflow: "hidden" }), e) {
27176
27182
  default:
27177
27183
  this.objects.forEach((i, s) => {
27178
27184
  i.dom?.css({
27179
27185
  position: "absolute",
27180
27186
  "z-index": String(1e3 + s),
27181
27187
  "backface-visibility": "hidden"
27188
+ // "transform-origin": "top left"
27182
27189
  });
27183
27190
  });
27184
27191
  break;
27185
27192
  }
27186
27193
  this.animates[e].forEach((i, s) => {
27187
27194
  const a = this.objects[s];
27188
- let n, o;
27189
- Array.isArray(i.attributeName) ? (n = i.attributeName, o = i.values) : (n = [i.attributeName], o = [i.values]), i.keyTimes.forEach((l, h) => {
27190
- const f = {};
27195
+ let n = [], o = [];
27196
+ Array.isArray(i.attributeName) ? (n = i.attributeName, o = i.values) : i.attributeName && (n = [i.attributeName], o = [i.values]), i.keyTimes.forEach((l, h) => {
27197
+ const f = {
27198
+ // transform: obj.dom?.css("transform") ?? ""
27199
+ };
27191
27200
  n.forEach((d, c) => {
27192
27201
  const u = o[c][h];
27193
- switch (d) {
27194
- case "translate":
27195
- Object.assign(f, {
27196
- transform: `${f.transform ?? ""} translate3d(${u[0] ?? 0}px, ${u[1] ?? 0}px, ${u[2] ?? 0}px)`
27197
- });
27198
- break;
27199
- case "rotateX":
27200
- Object.assign(f, {
27201
- transform: `${f.transform ?? ""} rotateX(${u ?? 0}deg)`
27202
- });
27203
- break;
27204
- case "rotateY":
27205
- Object.assign(f, {
27206
- transform: `${f.transform ?? ""} rotateY(${u ?? 0}deg)`
27207
- });
27208
- break;
27209
- case "scale":
27210
- Object.assign(f, {
27211
- transform: `${f.transform ?? ""} scale(${u ?? 0})`
27212
- });
27213
- break;
27214
- case "opacity":
27215
- Object.assign(f, {
27216
- opacity: `${u ?? 0}`
27217
- });
27218
- break;
27219
- }
27202
+ this._transformAttributeToCSSObject(d, u, f);
27220
27203
  }), h == 0 ? a.dom?.css(
27221
27204
  Object.assign(f, {
27222
27205
  transition: ""
@@ -27230,15 +27213,47 @@ class lT {
27230
27213
  })
27231
27214
  );
27232
27215
  }, i.begin), setTimeout(() => {
27233
- a.dom?.css({
27234
- transition: "",
27235
- transform: ""
27236
- });
27216
+ i.fill === "remove" && a.dom?.css(a.originCSSObject ?? {});
27237
27217
  }, i.begin + i.dur);
27238
27218
  });
27239
27219
  });
27240
27220
  }
27241
- addAnimate(e, t) {
27221
+ _transformAttributeToCSSObject(e, t, i = {}) {
27222
+ switch (e) {
27223
+ case "translate":
27224
+ Object.assign(i, {
27225
+ transform: `${i.transform ?? ""} translate3d(${t[0] ?? 0}px, ${t[1] ?? 0}px, ${t[2] ?? 0}px)`
27226
+ });
27227
+ break;
27228
+ case "rotateX":
27229
+ Object.assign(i, {
27230
+ transform: `${i.transform ?? ""} rotateX(${t ?? 0}deg)`
27231
+ });
27232
+ break;
27233
+ case "rotateY":
27234
+ Object.assign(i, {
27235
+ transform: `${i.transform ?? ""} rotateY(${t ?? 0}deg)`
27236
+ });
27237
+ break;
27238
+ case "scale":
27239
+ Object.assign(i, {
27240
+ transform: `${i.transform ?? ""} scale(${t ?? 0})`
27241
+ });
27242
+ break;
27243
+ case "opacity":
27244
+ Object.assign(i, {
27245
+ opacity: `${t ?? 0}`
27246
+ });
27247
+ break;
27248
+ case "display":
27249
+ Object.assign(i, {
27250
+ display: `${t === "block" ? "block" : "none"}`
27251
+ });
27252
+ break;
27253
+ }
27254
+ return i;
27255
+ }
27256
+ _addAnimate(e, t) {
27242
27257
  Object.prototype.hasOwnProperty.call(this.animates, e) || (this.animates[e] = [], t.forEach((i) => {
27243
27258
  this.animates[e].push(
27244
27259
  Object.assign(i, {
@@ -27248,7 +27263,55 @@ class lT {
27248
27263
  }));
27249
27264
  }
27250
27265
  ////////////////////////////////////////////////////////////////////
27251
- slideLeft(e = "ease", t = 300, i = 0) {
27266
+ // FLIP stands for First, Last, Invert, Play
27267
+ // - First:
27268
+ // the initial state of the element(s) involved in the transition.
27269
+ // - Last:
27270
+ // the final state of the element(s).
27271
+ // - Invert:
27272
+ // here's the fun bit.
27273
+ // You figure out from the first and last how the element has changed, so - say - its width, height, opacity.
27274
+ // Next you apply transforms and opacity changes to reverse, or invert, them.
27275
+ // If the element has moved 90px down between First and Last, you would apply a transform of -90px in Y.
27276
+ // This makes the elements appear as though they're still in the First position but, crucially, they're not.
27277
+ // - Play:
27278
+ // switch on transitions for any of the properties you changed, and then remove the inversion changes.
27279
+ // Because the element or elements are in their final position removing the transforms and opacities will ease them from their faux First position, out to the Last position.
27280
+ _flip(e = "ease", t = 300, i = 0) {
27281
+ if (this.objects.length == 2) {
27282
+ const s = this.objects[0].el?.getBoundingClientRect();
27283
+ this.objects[0].dom?.hide(), this.objects[0].originCSSObject = this.objects[0].dom?.css(), this.objects[1].dom?.show(), this.objects[1].originCSSObject = this.objects[1].dom?.css();
27284
+ const a = this.objects[1].el?.getBoundingClientRect();
27285
+ console.log(s, a), s && a && this._addAnimate("flip", [
27286
+ {
27287
+ attributeName: "",
27288
+ begin: i,
27289
+ dur: t,
27290
+ values: [],
27291
+ keyTimes: [],
27292
+ keySplines: [],
27293
+ fill: "remove"
27294
+ },
27295
+ {
27296
+ attributeName: ["display", "translate", "scale"],
27297
+ begin: i,
27298
+ dur: t,
27299
+ values: [
27300
+ ["block", "block"],
27301
+ [
27302
+ [s.left - a.left, s.top - a.top],
27303
+ [0, 0]
27304
+ ],
27305
+ [s.width / a.width, 1]
27306
+ ],
27307
+ keyTimes: [0, 1],
27308
+ keySplines: [Xe(e)],
27309
+ fill: "remove"
27310
+ }
27311
+ ]);
27312
+ }
27313
+ }
27314
+ _slideLeft(e = "ease", t = 300, i = 0) {
27252
27315
  const s = [];
27253
27316
  this.objects.length == 1 ? s.push({
27254
27317
  attributeName: ["opacity", "translate"],
@@ -27283,9 +27346,9 @@ class lT {
27283
27346
  ],
27284
27347
  keyTimes: [0, 1],
27285
27348
  keySplines: [Xe(e)]
27286
- })), this.addAnimate("slideLeft", s);
27349
+ })), this._addAnimate("slideLeft", s);
27287
27350
  }
27288
- slideRight(e = "ease", t = 300, i = 0) {
27351
+ _slideRight(e = "ease", t = 300, i = 0) {
27289
27352
  const s = [];
27290
27353
  this.objects.length == 1 ? s.push({
27291
27354
  attributeName: ["opacity", "translate"],
@@ -27320,9 +27383,9 @@ class lT {
27320
27383
  ],
27321
27384
  keyTimes: [0, 1],
27322
27385
  keySplines: [Xe(e)]
27323
- })), this.addAnimate("slideRight", s);
27386
+ })), this._addAnimate("slideRight", s);
27324
27387
  }
27325
- slideDown(e = "ease", t = 300, i = 0) {
27388
+ _slideDown(e = "ease", t = 300, i = 0) {
27326
27389
  const s = [];
27327
27390
  this.objects.length == 1 ? s.push({
27328
27391
  attributeName: ["opacity", "translate"],
@@ -27357,9 +27420,9 @@ class lT {
27357
27420
  ],
27358
27421
  keyTimes: [0, 1],
27359
27422
  keySplines: [Xe(e)]
27360
- })), this.addAnimate("slideDown", s);
27423
+ })), this._addAnimate("slideDown", s);
27361
27424
  }
27362
- slideUp(e = "ease", t = 300, i = 0) {
27425
+ _slideUp(e = "ease", t = 300, i = 0) {
27363
27426
  const s = [];
27364
27427
  this.objects.length == 1 ? s.push({
27365
27428
  attributeName: ["opacity", "translate"],
@@ -27394,9 +27457,9 @@ class lT {
27394
27457
  ],
27395
27458
  keyTimes: [0, 1],
27396
27459
  keySplines: [Xe(e)]
27397
- })), this.addAnimate("slideUp", s);
27460
+ })), this._addAnimate("slideUp", s);
27398
27461
  }
27399
- flipLeft(e = "ease", t = 300, i = 0) {
27462
+ _flipLeft(e = "ease", t = 300, i = 0) {
27400
27463
  const s = [];
27401
27464
  this.objects.length == 1 ? s.push({
27402
27465
  attributeName: ["opacity", "rotateY"],
@@ -27422,9 +27485,9 @@ class lT {
27422
27485
  values: [-180, 0],
27423
27486
  keyTimes: [0, 1],
27424
27487
  keySplines: [Xe(e)]
27425
- })), this.addAnimate("flipLeft", s);
27488
+ })), this._addAnimate("flipLeft", s);
27426
27489
  }
27427
- flipRight(e = "ease", t = 300, i = 0) {
27490
+ _flipRight(e = "ease", t = 300, i = 0) {
27428
27491
  const s = [];
27429
27492
  this.objects.length == 1 ? s.push({
27430
27493
  attributeName: ["opacity", "rotateY"],
@@ -27450,9 +27513,9 @@ class lT {
27450
27513
  values: [180, 0],
27451
27514
  keyTimes: [0, 1],
27452
27515
  keySplines: [Xe(e)]
27453
- })), this.addAnimate("flipRight", s);
27516
+ })), this._addAnimate("flipRight", s);
27454
27517
  }
27455
- flipDown(e = "ease", t = 300, i = 0) {
27518
+ _flipDown(e = "ease", t = 300, i = 0) {
27456
27519
  const s = [];
27457
27520
  this.objects.length == 1 ? s.push({
27458
27521
  attributeName: ["opacity", "rotateX"],
@@ -27478,9 +27541,9 @@ class lT {
27478
27541
  values: [180, 0],
27479
27542
  keyTimes: [0, 1],
27480
27543
  keySplines: [Xe(e)]
27481
- })), this.addAnimate("flipDown", s);
27544
+ })), this._addAnimate("flipDown", s);
27482
27545
  }
27483
- flipUp(e = "ease", t = 300, i = 0) {
27546
+ _flipUp(e = "ease", t = 300, i = 0) {
27484
27547
  const s = [];
27485
27548
  this.objects.length == 1 ? s.push({
27486
27549
  attributeName: ["opacity", "rotateX"],
@@ -27506,9 +27569,9 @@ class lT {
27506
27569
  values: [-180, 0],
27507
27570
  keyTimes: [0, 1],
27508
27571
  keySplines: [Xe(e)]
27509
- })), this.addAnimate("flipUp", s);
27572
+ })), this._addAnimate("flipUp", s);
27510
27573
  }
27511
- popIn(e = "ease", t = 300, i = 0) {
27574
+ _popIn(e = "ease", t = 300, i = 0) {
27512
27575
  const s = [];
27513
27576
  this.objects.length == 1 ? s.push({
27514
27577
  attributeName: ["translate", "scale", "opacity"],
@@ -27548,9 +27611,9 @@ class lT {
27548
27611
  ],
27549
27612
  keyTimes: [0, 1],
27550
27613
  keySplines: [Xe(e)]
27551
- })), this.addAnimate("popIn", s);
27614
+ })), this._addAnimate("popIn", s);
27552
27615
  }
27553
- popOut(e = "ease", t = 300, i = 0) {
27616
+ _popOut(e = "ease", t = 300, i = 0) {
27554
27617
  const s = [];
27555
27618
  this.objects.length == 1 ? s.push({
27556
27619
  attributeName: ["translate", "scale", "opacity"],
@@ -27593,7 +27656,7 @@ class lT {
27593
27656
  ],
27594
27657
  keyTimes: [0, 1],
27595
27658
  keySplines: [Xe(e)]
27596
- })), this.addAnimate("popOut", s);
27659
+ })), this._addAnimate("popOut", s);
27597
27660
  }
27598
27661
  }
27599
27662
  var Lh = null;