@ethlete/core 1.1.1 → 1.2.0

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.
@@ -362,6 +362,73 @@ const fromNextFrame = () => {
362
362
  const forceReflow = (element = document.body) => {
363
363
  return element.offsetHeight;
364
364
  };
365
+ const createFlipAnimation = (config) => {
366
+ const { element: el, duration = 250, easing = 'cubic-bezier(0.4, 0, 0.2, 1)' } = config;
367
+ let initialRect = el.getBoundingClientRect();
368
+ let animation = null;
369
+ const onStart$ = new Subject();
370
+ const onFinish$ = new Subject();
371
+ const onCancel$ = new Subject();
372
+ const onAnimationFinish = () => {
373
+ cleanup();
374
+ onFinish$.next();
375
+ };
376
+ const onAnimationCancel = () => {
377
+ cleanup();
378
+ onCancel$.next();
379
+ };
380
+ const cleanup = () => {
381
+ if (!animation) {
382
+ return;
383
+ }
384
+ animation.removeEventListener('finish', onAnimationFinish);
385
+ animation.removeEventListener('cancel', onAnimationCancel);
386
+ };
387
+ const updateInit = () => {
388
+ initialRect = el.getBoundingClientRect();
389
+ };
390
+ const play = () => {
391
+ const lastRect = el.getBoundingClientRect();
392
+ const delta = {
393
+ x: initialRect.left - lastRect.left,
394
+ y: initialRect.top - lastRect.top,
395
+ scaleX: initialRect.width / lastRect.width,
396
+ scaleY: initialRect.height / lastRect.height,
397
+ };
398
+ animation = el.animate([
399
+ {
400
+ transformOrigin: 'top left',
401
+ transform: `
402
+ translate(${delta.x}px, ${delta.y}px)
403
+ scale(${delta.scaleX}, ${delta.scaleY})
404
+ `,
405
+ },
406
+ {
407
+ transformOrigin: 'top left',
408
+ transform: 'none',
409
+ },
410
+ ], {
411
+ duration,
412
+ easing,
413
+ fill: 'both',
414
+ });
415
+ animation.addEventListener('finish', onAnimationFinish);
416
+ animation.addEventListener('cancel', onAnimationCancel);
417
+ onStart$.next();
418
+ };
419
+ const cancel = () => {
420
+ animation?.cancel();
421
+ cleanup();
422
+ };
423
+ return {
424
+ updateInit,
425
+ play,
426
+ cancel,
427
+ onStart$: onStart$.asObservable(),
428
+ onFinish$: onFinish$.asObservable(),
429
+ onCancel$: onCancel$.asObservable(),
430
+ };
431
+ };
365
432
 
366
433
  const clamp = (value, min = 0, max = 100) => {
367
434
  return Math.max(min, Math.min(max, value));
@@ -2446,5 +2513,5 @@ const Validators = {
2446
2513
  * Generated bundle index. Do not edit.
2447
2514
  */
2448
2515
 
2449
- export { ANIMATABLE_TOKEN, ANIMATED_LIFECYCLE_TOKEN, AnimatableDirective, AnimatedLifecycleDirective, ClickObserverFactory, ClickObserverService, ClickOutsideDirective, ContentObserverService, CursorDragScrollDirective, DEFAULT_VIEWPORT_CONFIG, DestroyService, FocusVisibleService, IS_ARRAY_NOT_EMPTY, IS_EMAIL, IsArrayNotEmpty, IsEmail, LetContext, LetDirective, MUST_MATCH, Memo, MustMatch, MutationObserverFactory, NormalizeGameResultTypePipe, NormalizeMatchParticipantsPipe, NormalizeMatchScorePipe, NormalizeMatchStatePipe, NormalizeMatchTypePipe, OBSERVE_SCROLL_STATE, ObserveContentDirective, ObserveResizeDirective, ObserveScrollStateDirective, RepeatDirective, ResizeObserverFactory, ResizeObserverService, RouterStateService, SCROLL_OBSERVER_FIRST_ELEMENT_CLASS, SCROLL_OBSERVER_IGNORE_TARGET_CLASS, SCROLL_OBSERVER_LAST_ELEMENT_CLASS, SEO_DIRECTIVE_TOKEN, ScrollObserverFirstElementDirective, ScrollObserverIgnoreTargetDirective, ScrollObserverLastElementDirective, SeoDirective, StructuredDataComponent, ToArrayPipe, TypedQueryList, VIEWPORT_CONFIG, Validators, ViewportService, clamp, clone, createMediaQueryObservable, createReactiveBindings, deleteCookie, elementCanScroll, equal, forceReflow, fromNextFrame, getCookie, getDomain, getGroupMatchPoints, getGroupMatchScore, getKnockoutMatchScore, getMatchScoreSubLine, hasCookie, isGroupMatch, isKnockoutMatch, mergeSeoConfig, nextFrame, normalizeGameResultType, normalizeMatchParticipant, normalizeMatchParticipants, normalizeMatchScore, normalizeMatchState, normalizeMatchType, provideViewportConfig, routerDisableScrollTop, setCookie, toArray, toArrayTrackByFn };
2516
+ export { ANIMATABLE_TOKEN, ANIMATED_LIFECYCLE_TOKEN, AnimatableDirective, AnimatedLifecycleDirective, ClickObserverFactory, ClickObserverService, ClickOutsideDirective, ContentObserverService, CursorDragScrollDirective, DEFAULT_VIEWPORT_CONFIG, DestroyService, FocusVisibleService, IS_ARRAY_NOT_EMPTY, IS_EMAIL, IsArrayNotEmpty, IsEmail, LetContext, LetDirective, MUST_MATCH, Memo, MustMatch, MutationObserverFactory, NormalizeGameResultTypePipe, NormalizeMatchParticipantsPipe, NormalizeMatchScorePipe, NormalizeMatchStatePipe, NormalizeMatchTypePipe, OBSERVE_SCROLL_STATE, ObserveContentDirective, ObserveResizeDirective, ObserveScrollStateDirective, RepeatDirective, ResizeObserverFactory, ResizeObserverService, RouterStateService, SCROLL_OBSERVER_FIRST_ELEMENT_CLASS, SCROLL_OBSERVER_IGNORE_TARGET_CLASS, SCROLL_OBSERVER_LAST_ELEMENT_CLASS, SEO_DIRECTIVE_TOKEN, ScrollObserverFirstElementDirective, ScrollObserverIgnoreTargetDirective, ScrollObserverLastElementDirective, SeoDirective, StructuredDataComponent, ToArrayPipe, TypedQueryList, VIEWPORT_CONFIG, Validators, ViewportService, clamp, clone, createFlipAnimation, createMediaQueryObservable, createReactiveBindings, deleteCookie, elementCanScroll, equal, forceReflow, fromNextFrame, getCookie, getDomain, getGroupMatchPoints, getGroupMatchScore, getKnockoutMatchScore, getMatchScoreSubLine, hasCookie, isGroupMatch, isKnockoutMatch, mergeSeoConfig, nextFrame, normalizeGameResultType, normalizeMatchParticipant, normalizeMatchParticipants, normalizeMatchScore, normalizeMatchState, normalizeMatchType, provideViewportConfig, routerDisableScrollTop, setCookie, toArray, toArrayTrackByFn };
2450
2517
  //# sourceMappingURL=ethlete-core.mjs.map