@ssgoi/core 0.0.1

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 (74) hide show
  1. package/README.md +34 -0
  2. package/dist/animator.d.ts +41 -0
  3. package/dist/animator.d.ts.map +1 -0
  4. package/dist/create-ssgoi-transition-context.d.ts +15 -0
  5. package/dist/create-ssgoi-transition-context.d.ts.map +1 -0
  6. package/dist/create-transition-callback.d.ts +36 -0
  7. package/dist/create-transition-callback.d.ts.map +1 -0
  8. package/dist/index.d.ts +4 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/ssgoi.cjs +1 -0
  11. package/dist/ssgoi.js +1 -0
  12. package/dist/ssgoi2.cjs +1 -0
  13. package/dist/ssgoi2.js +305 -0
  14. package/dist/ssgoi3.cjs +1 -0
  15. package/dist/ssgoi3.js +173 -0
  16. package/dist/ssgoi4.cjs +1 -0
  17. package/dist/ssgoi4.js +764 -0
  18. package/dist/transition.d.ts +16 -0
  19. package/dist/transition.d.ts.map +1 -0
  20. package/dist/transitions/blur.d.ts +27 -0
  21. package/dist/transitions/blur.d.ts.map +1 -0
  22. package/dist/transitions/bounce.d.ts +27 -0
  23. package/dist/transitions/bounce.d.ts.map +1 -0
  24. package/dist/transitions/fade.d.ts +26 -0
  25. package/dist/transitions/fade.d.ts.map +1 -0
  26. package/dist/transitions/index.d.ts +8 -0
  27. package/dist/transitions/index.d.ts.map +1 -0
  28. package/dist/transitions/none.d.ts +24 -0
  29. package/dist/transitions/none.d.ts.map +1 -0
  30. package/dist/transitions/rotate.d.ts +28 -0
  31. package/dist/transitions/rotate.d.ts.map +1 -0
  32. package/dist/transitions/scale.d.ts +27 -0
  33. package/dist/transitions/scale.d.ts.map +1 -0
  34. package/dist/transitions/slide.d.ts +27 -0
  35. package/dist/transitions/slide.d.ts.map +1 -0
  36. package/dist/transitions.d.ts +2 -0
  37. package/dist/types.d.ts +38 -0
  38. package/dist/types.d.ts.map +1 -0
  39. package/dist/utils-BSgyev81.cjs +1 -0
  40. package/dist/utils-DR41YsAh.js +16 -0
  41. package/dist/utils.d.ts +11 -0
  42. package/dist/utils.d.ts.map +1 -0
  43. package/dist/view-transitions/fade.d.ts +7 -0
  44. package/dist/view-transitions/fade.d.ts.map +1 -0
  45. package/dist/view-transitions/hero.d.ts +8 -0
  46. package/dist/view-transitions/hero.d.ts.map +1 -0
  47. package/dist/view-transitions/index.d.ts +5 -0
  48. package/dist/view-transitions/index.d.ts.map +1 -0
  49. package/dist/view-transitions/pinterest.d.ts +8 -0
  50. package/dist/view-transitions/pinterest.d.ts.map +1 -0
  51. package/dist/view-transitions/ripple.d.ts +7 -0
  52. package/dist/view-transitions/ripple.d.ts.map +1 -0
  53. package/dist/view-transitions.d.ts +2 -0
  54. package/package.json +58 -0
  55. package/src/lib/animator.ts +172 -0
  56. package/src/lib/create-ssgoi-transition-context.ts +265 -0
  57. package/src/lib/create-transition-callback.ts +246 -0
  58. package/src/lib/index.ts +3 -0
  59. package/src/lib/transition.ts +76 -0
  60. package/src/lib/transitions/blur.ts +55 -0
  61. package/src/lib/transitions/bounce.ts +61 -0
  62. package/src/lib/transitions/fade.ts +33 -0
  63. package/src/lib/transitions/index.ts +7 -0
  64. package/src/lib/transitions/none.ts +27 -0
  65. package/src/lib/transitions/rotate.ts +57 -0
  66. package/src/lib/transitions/scale.ts +34 -0
  67. package/src/lib/transitions/slide.ts +53 -0
  68. package/src/lib/types.ts +60 -0
  69. package/src/lib/utils.ts +39 -0
  70. package/src/lib/view-transitions/fade.ts +29 -0
  71. package/src/lib/view-transitions/hero.ts +179 -0
  72. package/src/lib/view-transitions/index.ts +4 -0
  73. package/src/lib/view-transitions/pinterest.ts +403 -0
  74. package/src/lib/view-transitions/ripple.ts +45 -0
@@ -0,0 +1,16 @@
1
+ import { Transition, TransitionCallback } from './types';
2
+ /**
3
+ * Key type for transitions - can be string or symbol
4
+ */
5
+ type TransitionKey = string | symbol;
6
+ /**
7
+ * Framework-agnostic transition function that can be used as a ref
8
+ * Usage: <div ref={transition({ key: 'fade', in, out })} />
9
+ */
10
+ export declare function transition(options: {
11
+ key: TransitionKey;
12
+ in?: Transition["in"];
13
+ out?: Transition["out"];
14
+ }): TransitionCallback;
15
+ export {};
16
+ //# sourceMappingURL=transition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../src/lib/transition.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE9D;;GAEG;AACH,KAAK,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;AAuDrC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAClC,GAAG,EAAE,aAAa,CAAC;IACnB,EAAE,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IACtB,GAAG,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;CACzB,GAAG,kBAAkB,CAMrB"}
@@ -0,0 +1,27 @@
1
+ interface BlurOptions {
2
+ amount?: number;
3
+ scale?: boolean;
4
+ fade?: boolean;
5
+ spring?: {
6
+ stiffness?: number;
7
+ damping?: number;
8
+ };
9
+ }
10
+ export declare const blur: (options?: BlurOptions) => {
11
+ in: (element: HTMLElement) => {
12
+ spring: {
13
+ stiffness?: number;
14
+ damping?: number;
15
+ };
16
+ tick: (progress: number) => void;
17
+ };
18
+ out: (element: HTMLElement) => {
19
+ spring: {
20
+ stiffness?: number;
21
+ damping?: number;
22
+ };
23
+ tick: (progress: number) => void;
24
+ };
25
+ };
26
+ export {};
27
+ //# sourceMappingURL=blur.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blur.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/blur.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,IAAI,GAAI,UAAS,WAAgB;kBAS5B,WAAW;;wBAdb,MAAM;sBACR,MAAM;;yBAeG,MAAM;;mBAeV,WAAW;;wBA/Bd,MAAM;sBACR,MAAM;;yBAgCG,MAAM;;CAgB5B,CAAC"}
@@ -0,0 +1,27 @@
1
+ interface BounceOptions {
2
+ height?: number;
3
+ scale?: boolean;
4
+ fade?: boolean;
5
+ spring?: {
6
+ stiffness?: number;
7
+ damping?: number;
8
+ };
9
+ }
10
+ export declare const bounce: (options?: BounceOptions) => {
11
+ in: (element: HTMLElement) => {
12
+ spring: {
13
+ stiffness?: number;
14
+ damping?: number;
15
+ };
16
+ tick: (progress: number) => void;
17
+ };
18
+ out: (element: HTMLElement) => {
19
+ spring: {
20
+ stiffness?: number;
21
+ damping?: number;
22
+ };
23
+ tick: (progress: number) => void;
24
+ };
25
+ };
26
+ export {};
27
+ //# sourceMappingURL=bounce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounce.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/bounce.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,MAAM,GAAI,UAAS,aAAkB;kBAShC,WAAW;;wBAdb,MAAM;sBACR,MAAM;;yBAeG,MAAM;;mBAkBV,WAAW;;wBAlCd,MAAM;sBACR,MAAM;;yBAmCG,MAAM;;CAmB5B,CAAC"}
@@ -0,0 +1,26 @@
1
+ interface FadeOptions {
2
+ from?: number;
3
+ to?: number;
4
+ spring?: {
5
+ stiffness?: number;
6
+ damping?: number;
7
+ };
8
+ }
9
+ export declare const fade: (options?: FadeOptions) => {
10
+ in: (element: HTMLElement) => {
11
+ spring: {
12
+ stiffness?: number;
13
+ damping?: number;
14
+ };
15
+ tick: (progress: number) => void;
16
+ };
17
+ out: (element: HTMLElement) => {
18
+ spring: {
19
+ stiffness?: number;
20
+ damping?: number;
21
+ };
22
+ tick: (progress: number) => void;
23
+ };
24
+ };
25
+ export {};
26
+ //# sourceMappingURL=fade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fade.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/fade.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,IAAI,GAAI,UAAS,WAAgB;kBAQ5B,WAAW;;wBAbb,MAAM;sBACR,MAAM;;yBAcG,MAAM;;mBAKV,WAAW;;wBApBd,MAAM;sBACR,MAAM;;yBAqBG,MAAM;;CAM5B,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from './fade';
2
+ export * from './scale';
3
+ export * from './slide';
4
+ export * from './rotate';
5
+ export * from './bounce';
6
+ export * from './blur';
7
+ export * from './none';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,24 @@
1
+ interface NoneOptions {
2
+ spring?: {
3
+ stiffness?: number;
4
+ damping?: number;
5
+ };
6
+ }
7
+ export declare const none: (options?: NoneOptions) => {
8
+ in: (_element: HTMLElement) => {
9
+ spring: {
10
+ stiffness?: number;
11
+ damping?: number;
12
+ };
13
+ tick: (_progress: number) => void;
14
+ };
15
+ out: (_element: HTMLElement) => {
16
+ spring: {
17
+ stiffness?: number;
18
+ damping?: number;
19
+ };
20
+ tick: (_progress: number) => void;
21
+ };
22
+ };
23
+ export {};
24
+ //# sourceMappingURL=none.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"none.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/none.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,IAAI,GAAI,UAAS,WAAgB;mBAM3B,WAAW;;wBAXd,MAAM;sBACR,MAAM;;0BAYI,MAAM;;oBAIV,WAAW;;wBAjBf,MAAM;sBACR,MAAM;;0BAkBI,MAAM;;CAK7B,CAAC"}
@@ -0,0 +1,28 @@
1
+ interface RotateOptions {
2
+ degrees?: number;
3
+ clockwise?: boolean;
4
+ scale?: boolean;
5
+ fade?: boolean;
6
+ spring?: {
7
+ stiffness?: number;
8
+ damping?: number;
9
+ };
10
+ }
11
+ export declare const rotate: (options?: RotateOptions) => {
12
+ in: (element: HTMLElement) => {
13
+ spring: {
14
+ stiffness?: number;
15
+ damping?: number;
16
+ };
17
+ tick: (progress: number) => void;
18
+ };
19
+ out: (element: HTMLElement) => {
20
+ spring: {
21
+ stiffness?: number;
22
+ damping?: number;
23
+ };
24
+ tick: (progress: number) => void;
25
+ };
26
+ };
27
+ export {};
28
+ //# sourceMappingURL=rotate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rotate.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/rotate.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,MAAM,GAAI,UAAS,aAAkB;kBAYhC,WAAW;;wBAjBb,MAAM;sBACR,MAAM;;yBAkBG,MAAM;;mBAcV,WAAW;;wBAjCd,MAAM;sBACR,MAAM;;yBAkCG,MAAM;;CAe5B,CAAC"}
@@ -0,0 +1,27 @@
1
+ interface ScaleOptions {
2
+ duration?: number;
3
+ from?: number;
4
+ to?: number;
5
+ spring?: {
6
+ stiffness?: number;
7
+ damping?: number;
8
+ };
9
+ }
10
+ export declare const scale: (options?: ScaleOptions) => {
11
+ in: (element: HTMLElement) => {
12
+ spring: {
13
+ stiffness?: number;
14
+ damping?: number;
15
+ };
16
+ tick: (progress: number) => void;
17
+ };
18
+ out: (element: HTMLElement) => {
19
+ spring: {
20
+ stiffness?: number;
21
+ damping?: number;
22
+ };
23
+ tick: (progress: number) => void;
24
+ };
25
+ };
26
+ export {};
27
+ //# sourceMappingURL=scale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scale.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/scale.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,KAAK,GAAI,UAAS,YAAiB;kBAQ9B,WAAW;;wBAbb,MAAM;sBACR,MAAM;;yBAcG,MAAM;;mBAKV,WAAW;;wBApBd,MAAM;sBACR,MAAM;;yBAqBG,MAAM;;CAM5B,CAAC"}
@@ -0,0 +1,27 @@
1
+ interface SlideOptions {
2
+ direction?: 'left' | 'right' | 'up' | 'down';
3
+ distance?: number;
4
+ fade?: boolean;
5
+ spring?: {
6
+ stiffness?: number;
7
+ damping?: number;
8
+ };
9
+ }
10
+ export declare const slide: (options?: SlideOptions) => {
11
+ in: (element: HTMLElement) => {
12
+ spring: {
13
+ stiffness?: number;
14
+ damping?: number;
15
+ };
16
+ tick: (progress: number) => void;
17
+ };
18
+ out: (element: HTMLElement) => {
19
+ spring: {
20
+ stiffness?: number;
21
+ damping?: number;
22
+ };
23
+ tick: (progress: number) => void;
24
+ };
25
+ };
26
+ export {};
27
+ //# sourceMappingURL=slide.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slide.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/slide.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,KAAK,GAAI,UAAS,YAAiB;kBAuB9B,WAAW;;wBA5Bb,MAAM;sBACR,MAAM;;yBA6BG,MAAM;;mBAOV,WAAW;;wBArCd,MAAM;sBACR,MAAM;;yBAsCG,MAAM;;CAQ5B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './transitions/index'
2
+ export {}
@@ -0,0 +1,38 @@
1
+ export type TransitionKey = string | symbol;
2
+ export type SpringConfig = {
3
+ stiffness?: number;
4
+ damping?: number;
5
+ };
6
+ export type TransitionConfig = {
7
+ spring?: SpringConfig;
8
+ tick?: (progress: number) => void;
9
+ prepare?: (element: HTMLElement) => void;
10
+ onStart?: () => void;
11
+ onEnd?: () => void;
12
+ };
13
+ export type GetTransitionConfig<TContext = undefined> = TContext extends undefined ? (node: HTMLElement) => TransitionConfig | Promise<TransitionConfig> : (node: HTMLElement, context: TContext) => TransitionConfig | Promise<TransitionConfig>;
14
+ export type Transition<TContext = undefined> = {
15
+ in?: GetTransitionConfig<TContext>;
16
+ out?: GetTransitionConfig<TContext>;
17
+ };
18
+ export type TransitionCallback = (element: HTMLElement | null) => void | (() => void);
19
+ export type SggoiTransitionContext = {
20
+ scrollOffset: {
21
+ x: number;
22
+ y: number;
23
+ };
24
+ };
25
+ export type SggoiTransition = Transition<SggoiTransitionContext>;
26
+ export type SsgoiConfig = {
27
+ transitions: {
28
+ from: string;
29
+ to: string;
30
+ transition: SggoiTransition;
31
+ symmetric?: boolean;
32
+ }[];
33
+ defaultTransition?: SggoiTransition;
34
+ };
35
+ export type SsgoiContext = (path: string) => Transition & {
36
+ key: TransitionKey;
37
+ };
38
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;AAE5C,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAE7B,MAAM,CAAC,EAAE,YAAY,CAAC;IAGtB,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAGlC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IAGzC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAGrB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,QAAQ,GAAG,SAAS,IAClD,QAAQ,SAAS,SAAS,GACtB,CAAC,IAAI,EAAE,WAAW,KAAK,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,GACnE,CACE,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,QAAQ,KACd,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAExD,MAAM,MAAM,UAAU,CAAC,QAAQ,GAAG,SAAS,IAAI;IAC7C,EAAE,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACnC,GAAG,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,EAAE,WAAW,GAAG,IAAI,KACxB,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AAEzB,MAAM,MAAM,sBAAsB,GAAG;IACnC,YAAY,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;AAEjE,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,UAAU,EAAE,eAAe,CAAC;QAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,EAAE,CAAC;IACJ,iBAAiB,CAAC,EAAE,eAAe,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,CACzB,IAAI,EAAE,MAAM,KACT,UAAU,GAAG;IAAE,GAAG,EAAE,aAAa,CAAA;CAAE,CAAC"}
@@ -0,0 +1 @@
1
+ "use strict";const n=e=>{e.style.position="absolute",e.style.width="100%",e.style.top="0",e.style.left="0"},r=e=>{let t=e.parentElement;for(;t&&t!==document.body;){const l=window.getComputedStyle(t),o=l.overflow+l.overflowY+l.overflowX;if(o.includes("auto")||o.includes("scroll")||t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.parentElement}return document.documentElement};exports.getScrollingElement=r;exports.prepareOutgoing=n;
@@ -0,0 +1,16 @@
1
+ const n = (e) => {
2
+ e.style.position = "absolute", e.style.width = "100%", e.style.top = "0", e.style.left = "0";
3
+ }, r = (e) => {
4
+ let t = e.parentElement;
5
+ for (; t && t !== document.body; ) {
6
+ const o = window.getComputedStyle(t), l = o.overflow + o.overflowY + o.overflowX;
7
+ if (l.includes("auto") || l.includes("scroll") || t.scrollHeight > t.clientHeight || t.scrollWidth > t.clientWidth)
8
+ return t;
9
+ t = t.parentElement;
10
+ }
11
+ return document.documentElement;
12
+ };
13
+ export {
14
+ r as g,
15
+ n as p
16
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Applies common styles for outgoing page elements
3
+ * Makes the element absolute positioned to allow the incoming page to take its place
4
+ */
5
+ export declare const prepareOutgoing: (element: HTMLElement) => void;
6
+ /**
7
+ * Gets the scrolling element that contains the given element
8
+ * Returns the first scrollable parent element or document.documentElement
9
+ */
10
+ export declare const getScrollingElement: (element: HTMLElement) => HTMLElement;
11
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/lib/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,WAAW,KAAG,IAKtD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,WAAW,KAAG,WAuB1D,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { SpringConfig, SggoiTransition } from '../types';
2
+ interface FadeOptions {
3
+ spring?: Partial<SpringConfig>;
4
+ }
5
+ export declare const fade: (options?: FadeOptions) => SggoiTransition;
6
+ export {};
7
+ //# sourceMappingURL=fade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fade.d.ts","sourceRoot":"","sources":["../../src/lib/view-transitions/fade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG9D,UAAU,WAAW;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;CAChC;AAED,eAAO,MAAM,IAAI,GAAI,UAAS,WAAgB,KAAG,eAqBhD,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { SpringConfig, SggoiTransition } from '../types';
2
+ interface HeroOptions {
3
+ spring?: Partial<SpringConfig>;
4
+ timeout?: number;
5
+ }
6
+ export declare const hero: (options?: HeroOptions) => SggoiTransition;
7
+ export {};
8
+ //# sourceMappingURL=hero.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hero.d.ts","sourceRoot":"","sources":["../../src/lib/view-transitions/hero.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG9D,UAAU,WAAW;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAkBD,eAAO,MAAM,IAAI,GAAI,UAAS,WAAgB,KAAG,eA0JhD,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './fade';
2
+ export * from './hero';
3
+ export * from './pinterest';
4
+ export * from './ripple';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/view-transitions/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { SpringConfig, SggoiTransition } from '../types';
2
+ interface PinterestOptions {
3
+ spring?: Partial<SpringConfig>;
4
+ timeout?: number;
5
+ }
6
+ export declare const pinterest: (options?: PinterestOptions) => SggoiTransition;
7
+ export {};
8
+ //# sourceMappingURL=pinterest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pinterest.d.ts","sourceRoot":"","sources":["../../src/lib/view-transitions/pinterest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG9D,UAAU,gBAAgB;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA0TD,eAAO,MAAM,SAAS,GAAI,UAAS,gBAAqB,KAAG,eAkF1D,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { SpringConfig, SggoiTransition } from '../types';
2
+ interface RippleOptions {
3
+ spring?: Partial<SpringConfig>;
4
+ }
5
+ export declare const ripple: (options?: RippleOptions) => SggoiTransition;
6
+ export {};
7
+ //# sourceMappingURL=ripple.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ripple.d.ts","sourceRoot":"","sources":["../../src/lib/view-transitions/ripple.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG9D,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;CAChC;AAWD,eAAO,MAAM,MAAM,GAAI,UAAS,aAAkB,KAAG,eA4BpD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './view-transitions/index'
2
+ export {}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@ssgoi/core",
3
+ "version": "0.0.1",
4
+ "description": "A smooth page transition library",
5
+ "private": false,
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs"
15
+ },
16
+ "./transitions": {
17
+ "types": "./dist/transitions/index.d.ts",
18
+ "import": "./dist/transitions/index.js",
19
+ "require": "./dist/transitions/index.cjs"
20
+ },
21
+ "./view-transitions": {
22
+ "types": "./dist/view-transitions/index.d.ts",
23
+ "import": "./dist/view-transitions/index.js",
24
+ "require": "./dist/view-transitions/index.cjs"
25
+ },
26
+ "./types": {
27
+ "types": "./dist/types.d.ts",
28
+ "import": "./dist/types.js",
29
+ "require": "./dist/types.cjs"
30
+ }
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "src"
35
+ ],
36
+ "keywords": [
37
+ "page-transition",
38
+ "animation",
39
+ "typescript",
40
+ "vanilla"
41
+ ],
42
+ "author": "",
43
+ "license": "MIT",
44
+ "devDependencies": {
45
+ "@types/node": "^22.10.6",
46
+ "typescript": "^5.7.3",
47
+ "vite": "^6.0.7",
48
+ "vite-plugin-dts": "^4.5.0"
49
+ },
50
+ "dependencies": {
51
+ "popmotion": "^11.0.5"
52
+ },
53
+ "scripts": {
54
+ "dev": "vite",
55
+ "build": "tsc && vite build",
56
+ "preview": "vite preview"
57
+ }
58
+ }
@@ -0,0 +1,172 @@
1
+ import { animate } from "popmotion";
2
+
3
+ import type { SpringConfig } from "./types";
4
+
5
+ export interface AnimationOptions {
6
+ from: number;
7
+ to: number;
8
+ spring: SpringConfig;
9
+ onUpdate: (value: number) => void;
10
+ onComplete: () => void;
11
+ onStart?: () => void;
12
+ }
13
+
14
+ /**
15
+ * New Animator implementation using Popmotion
16
+ * Provides spring-based animations with fine control
17
+ */
18
+ export class Animator {
19
+ private options: AnimationOptions;
20
+ private currentValue: number;
21
+ private velocity: number = 0;
22
+ private isAnimating = false;
23
+ private controls: { stop: () => void } | null = null;
24
+
25
+ constructor(options: Partial<AnimationOptions>) {
26
+ this.options = {
27
+ from: options.from ?? 0,
28
+ to: options.to ?? 1,
29
+ spring: options.spring ?? { stiffness: 100, damping: 10 },
30
+ onUpdate: options.onUpdate ?? (() => {}),
31
+ onComplete: options.onComplete ?? (() => {}),
32
+ onStart: options.onStart,
33
+ };
34
+ this.currentValue = this.options.from;
35
+ }
36
+
37
+ private animate = (reverse: boolean = false) => {
38
+ // Call onStart on first frame
39
+ if (!this.isAnimating && this.options.onStart) {
40
+ this.options.onStart();
41
+ }
42
+
43
+ this.isAnimating = true;
44
+
45
+ const target = reverse ? this.options.from : this.options.to;
46
+
47
+ // Track previous value for velocity calculation
48
+ let previousValue = this.currentValue;
49
+ let previousTime = performance.now();
50
+
51
+ // Create animation
52
+ this.controls = animate({
53
+ from: this.currentValue,
54
+ to: target,
55
+ velocity: this.velocity * 1000, // Convert to px/s
56
+ stiffness: this.options.spring.stiffness,
57
+ damping: this.options.spring.damping,
58
+ mass: 1,
59
+
60
+ onUpdate: (value: number) => {
61
+ const currentTime = performance.now();
62
+ const timeDelta = (currentTime - previousTime) / 1000; // Convert to seconds
63
+
64
+ if (timeDelta > 0) {
65
+ // Calculate velocity in units per second, then normalize
66
+ const rawVelocity = (value - previousValue) / timeDelta;
67
+ this.velocity = rawVelocity / 1000; // Normalize to 0-1 range
68
+
69
+ previousValue = value;
70
+ previousTime = currentTime;
71
+ }
72
+
73
+ this.currentValue = value;
74
+ this.options.onUpdate(value);
75
+ },
76
+ onComplete: () => {
77
+ this.currentValue = target;
78
+ this.isAnimating = false;
79
+ this.controls = null;
80
+ this.velocity = 0;
81
+ this.options.onComplete();
82
+ },
83
+ });
84
+ };
85
+
86
+ // Animation control methods
87
+ forward(): void {
88
+ this.stop();
89
+ this.animate(false);
90
+ }
91
+
92
+ backward(): void {
93
+ this.stop();
94
+ this.animate(true);
95
+ }
96
+
97
+ reverse(): void {
98
+ // Swap from and to
99
+ const temp = this.options.from;
100
+ this.options.from = this.options.to;
101
+ this.options.to = temp;
102
+
103
+ // If currently animating, restart with new direction
104
+ if (this.isAnimating) {
105
+ const wasReversed =
106
+ this.currentValue > (this.options.from + this.options.to) / 2;
107
+ this.stop();
108
+ this.animate(!wasReversed);
109
+ }
110
+ }
111
+
112
+ stop(): void {
113
+ this.isAnimating = false;
114
+ if (this.controls) {
115
+ this.controls.stop();
116
+ this.controls = null;
117
+ }
118
+ // Preserve velocity when stopping
119
+ }
120
+
121
+ // State getters
122
+ getVelocity(): number {
123
+ return this.velocity;
124
+ }
125
+
126
+ getCurrentValue(): number {
127
+ return this.currentValue;
128
+ }
129
+
130
+ getIsAnimating(): boolean {
131
+ return this.isAnimating;
132
+ }
133
+
134
+ getCurrentState(): { position: number; velocity: number } {
135
+ return {
136
+ position: this.currentValue,
137
+ velocity: this.velocity,
138
+ };
139
+ }
140
+
141
+ // State setters
142
+ setVelocity(velocity: number): void {
143
+ this.velocity = velocity;
144
+ }
145
+
146
+ setValue(value: number): void {
147
+ this.currentValue = value;
148
+ }
149
+
150
+ // Configuration
151
+ updateOptions(newOptions: Partial<AnimationOptions>): void {
152
+ this.options = { ...this.options, ...newOptions };
153
+
154
+ // If animating, restart with new options
155
+ if (this.isAnimating && this.controls) {
156
+ const currentDirection = this.currentValue < this.options.to;
157
+ this.stop();
158
+ this.animate(!currentDirection);
159
+ }
160
+ }
161
+
162
+ // Static factory method
163
+ static fromState(
164
+ state: { position: number; velocity: number },
165
+ newOptions: Partial<AnimationOptions>
166
+ ): Animator {
167
+ const animation = new Animator(newOptions);
168
+ animation.setValue(state.position);
169
+ animation.setVelocity(state.velocity);
170
+ return animation;
171
+ }
172
+ }