masoneffect 2.0.8 → 2.0.11

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 (182) hide show
  1. package/README.md +23 -25
  2. package/dist/core/index.d.ts +0 -1
  3. package/dist/core/index.d.ts.map +1 -1
  4. package/dist/core/scrollFadeIn/index.d.ts +4 -11
  5. package/dist/core/scrollFadeIn/index.d.ts.map +1 -1
  6. package/dist/core/typing/index.d.ts +2 -0
  7. package/dist/core/typing/index.d.ts.map +1 -1
  8. package/dist/core/utils/visibilityManager.d.ts +1 -0
  9. package/dist/core/utils/visibilityManager.d.ts.map +1 -1
  10. package/dist/count/core/index.d.ts +0 -1
  11. package/dist/count/core/index.d.ts.map +1 -1
  12. package/dist/count/core/scrollFadeIn/index.d.ts +4 -11
  13. package/dist/count/core/scrollFadeIn/index.d.ts.map +1 -1
  14. package/dist/count/core/typing/index.d.ts +2 -0
  15. package/dist/count/core/typing/index.d.ts.map +1 -1
  16. package/dist/count/core/utils/visibilityManager.d.ts +1 -0
  17. package/dist/count/core/utils/visibilityManager.d.ts.map +1 -1
  18. package/dist/count/index.cjs +1 -1
  19. package/dist/count/index.d.ts +0 -1
  20. package/dist/count/index.d.ts.map +1 -1
  21. package/dist/count/index.mjs +1 -1
  22. package/dist/count/react/index.d.ts +0 -1
  23. package/dist/count/react/index.d.ts.map +1 -1
  24. package/dist/count/react/scrollFadeIn/index.d.ts +0 -1
  25. package/dist/count/react/scrollFadeIn/index.d.ts.map +1 -1
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.d.ts +0 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.mjs +1 -1
  30. package/dist/index.umd.min.js +1 -1
  31. package/dist/react/core/index.d.ts +0 -1
  32. package/dist/react/core/scrollFadeIn/index.d.ts +4 -11
  33. package/dist/react/core/typing/index.d.ts +2 -0
  34. package/dist/react/core/utils/visibilityManager.d.ts +1 -0
  35. package/dist/react/count/core/index.d.ts +0 -1
  36. package/dist/react/count/core/index.d.ts.map +1 -1
  37. package/dist/react/count/core/scrollFadeIn/index.d.ts +4 -11
  38. package/dist/react/count/core/scrollFadeIn/index.d.ts.map +1 -1
  39. package/dist/react/count/core/typing/index.d.ts +2 -0
  40. package/dist/react/count/core/typing/index.d.ts.map +1 -1
  41. package/dist/react/count/core/utils/visibilityManager.d.ts +1 -0
  42. package/dist/react/count/core/utils/visibilityManager.d.ts.map +1 -1
  43. package/dist/react/count/index.cjs +1 -1
  44. package/dist/react/count/index.d.ts +0 -1
  45. package/dist/react/count/index.d.ts.map +1 -1
  46. package/dist/react/count/index.mjs +1 -1
  47. package/dist/react/count/react/index.d.ts +0 -1
  48. package/dist/react/count/react/index.d.ts.map +1 -1
  49. package/dist/react/count/react/scrollFadeIn/index.d.ts +0 -1
  50. package/dist/react/count/react/scrollFadeIn/index.d.ts.map +1 -1
  51. package/dist/react/index.cjs +0 -4
  52. package/dist/react/index.d.ts.map +1 -1
  53. package/dist/react/index.mjs +1 -1
  54. package/dist/react/react/index.d.ts +0 -1
  55. package/dist/react/react/scrollFadeIn/index.d.ts +0 -1
  56. package/dist/react/scrollFadeIn/core/index.d.ts +0 -1
  57. package/dist/react/scrollFadeIn/core/index.d.ts.map +1 -1
  58. package/dist/react/scrollFadeIn/core/scrollFadeIn/index.d.ts +4 -11
  59. package/dist/react/scrollFadeIn/core/scrollFadeIn/index.d.ts.map +1 -1
  60. package/dist/react/scrollFadeIn/core/typing/index.d.ts +2 -0
  61. package/dist/react/scrollFadeIn/core/typing/index.d.ts.map +1 -1
  62. package/dist/react/scrollFadeIn/core/utils/visibilityManager.d.ts +1 -0
  63. package/dist/react/scrollFadeIn/core/utils/visibilityManager.d.ts.map +1 -1
  64. package/dist/react/scrollFadeIn/index.cjs +1 -1
  65. package/dist/react/scrollFadeIn/index.d.ts +0 -1
  66. package/dist/react/scrollFadeIn/index.d.ts.map +1 -1
  67. package/dist/react/scrollFadeIn/index.mjs +1 -1
  68. package/dist/react/scrollFadeIn/react/index.d.ts +0 -1
  69. package/dist/react/scrollFadeIn/react/index.d.ts.map +1 -1
  70. package/dist/react/scrollFadeIn/react/scrollFadeIn/index.d.ts +0 -1
  71. package/dist/react/scrollFadeIn/react/scrollFadeIn/index.d.ts.map +1 -1
  72. package/dist/react/textToParticle/core/index.d.ts +0 -1
  73. package/dist/react/textToParticle/core/index.d.ts.map +1 -1
  74. package/dist/react/textToParticle/core/scrollFadeIn/index.d.ts +4 -11
  75. package/dist/react/textToParticle/core/scrollFadeIn/index.d.ts.map +1 -1
  76. package/dist/react/textToParticle/core/typing/index.d.ts +2 -0
  77. package/dist/react/textToParticle/core/typing/index.d.ts.map +1 -1
  78. package/dist/react/textToParticle/core/utils/visibilityManager.d.ts +1 -0
  79. package/dist/react/textToParticle/core/utils/visibilityManager.d.ts.map +1 -1
  80. package/dist/react/textToParticle/index.cjs +1 -1
  81. package/dist/react/textToParticle/index.d.ts +0 -1
  82. package/dist/react/textToParticle/index.d.ts.map +1 -1
  83. package/dist/react/textToParticle/index.mjs +1 -1
  84. package/dist/react/textToParticle/react/index.d.ts +0 -1
  85. package/dist/react/textToParticle/react/index.d.ts.map +1 -1
  86. package/dist/react/textToParticle/react/scrollFadeIn/index.d.ts +0 -1
  87. package/dist/react/textToParticle/react/scrollFadeIn/index.d.ts.map +1 -1
  88. package/dist/react/typing/core/index.d.ts +0 -1
  89. package/dist/react/typing/core/index.d.ts.map +1 -1
  90. package/dist/react/typing/core/scrollFadeIn/index.d.ts +4 -11
  91. package/dist/react/typing/core/scrollFadeIn/index.d.ts.map +1 -1
  92. package/dist/react/typing/core/typing/index.d.ts +2 -0
  93. package/dist/react/typing/core/typing/index.d.ts.map +1 -1
  94. package/dist/react/typing/core/utils/visibilityManager.d.ts +1 -0
  95. package/dist/react/typing/core/utils/visibilityManager.d.ts.map +1 -1
  96. package/dist/react/typing/index.cjs +1 -1
  97. package/dist/react/typing/index.d.ts +0 -1
  98. package/dist/react/typing/index.d.ts.map +1 -1
  99. package/dist/react/typing/index.mjs +1 -1
  100. package/dist/react/typing/react/index.d.ts +0 -1
  101. package/dist/react/typing/react/index.d.ts.map +1 -1
  102. package/dist/react/typing/react/scrollFadeIn/index.d.ts +0 -1
  103. package/dist/react/typing/react/scrollFadeIn/index.d.ts.map +1 -1
  104. package/dist/scrollFadeIn/core/index.d.ts +0 -1
  105. package/dist/scrollFadeIn/core/index.d.ts.map +1 -1
  106. package/dist/scrollFadeIn/core/scrollFadeIn/index.d.ts +4 -11
  107. package/dist/scrollFadeIn/core/scrollFadeIn/index.d.ts.map +1 -1
  108. package/dist/scrollFadeIn/core/typing/index.d.ts +2 -0
  109. package/dist/scrollFadeIn/core/typing/index.d.ts.map +1 -1
  110. package/dist/scrollFadeIn/core/utils/visibilityManager.d.ts +1 -0
  111. package/dist/scrollFadeIn/core/utils/visibilityManager.d.ts.map +1 -1
  112. package/dist/scrollFadeIn/index.cjs +1 -1
  113. package/dist/scrollFadeIn/index.d.ts +0 -1
  114. package/dist/scrollFadeIn/index.d.ts.map +1 -1
  115. package/dist/scrollFadeIn/index.mjs +1 -1
  116. package/dist/scrollFadeIn/react/index.d.ts +0 -1
  117. package/dist/scrollFadeIn/react/index.d.ts.map +1 -1
  118. package/dist/scrollFadeIn/react/scrollFadeIn/index.d.ts +0 -1
  119. package/dist/scrollFadeIn/react/scrollFadeIn/index.d.ts.map +1 -1
  120. package/dist/svelte/count/index.cjs +1 -1
  121. package/dist/svelte/count/index.d.ts +8 -6
  122. package/dist/svelte/count/index.mjs +5 -1
  123. package/dist/svelte/index.cjs +1 -1
  124. package/dist/svelte/index.d.ts +8 -6
  125. package/dist/svelte/index.mjs +88 -27
  126. package/dist/svelte/scrollFadeIn/index.cjs +1 -1
  127. package/dist/svelte/scrollFadeIn/index.d.ts +8 -6
  128. package/dist/svelte/scrollFadeIn/index.mjs +35 -24
  129. package/dist/svelte/textToParticle/index.cjs +1 -1
  130. package/dist/svelte/textToParticle/index.d.ts +8 -6
  131. package/dist/svelte/textToParticle/index.mjs +5 -1
  132. package/dist/svelte/typing/index.cjs +1 -1
  133. package/dist/svelte/typing/index.d.ts +8 -6
  134. package/dist/svelte/typing/index.mjs +56 -2
  135. package/dist/textToParticle/core/index.d.ts +0 -1
  136. package/dist/textToParticle/core/index.d.ts.map +1 -1
  137. package/dist/textToParticle/core/scrollFadeIn/index.d.ts +4 -11
  138. package/dist/textToParticle/core/scrollFadeIn/index.d.ts.map +1 -1
  139. package/dist/textToParticle/core/typing/index.d.ts +2 -0
  140. package/dist/textToParticle/core/typing/index.d.ts.map +1 -1
  141. package/dist/textToParticle/core/utils/visibilityManager.d.ts +1 -0
  142. package/dist/textToParticle/core/utils/visibilityManager.d.ts.map +1 -1
  143. package/dist/textToParticle/index.cjs +1 -1
  144. package/dist/textToParticle/index.d.ts +0 -1
  145. package/dist/textToParticle/index.d.ts.map +1 -1
  146. package/dist/textToParticle/index.mjs +1 -1
  147. package/dist/textToParticle/react/index.d.ts +0 -1
  148. package/dist/textToParticle/react/index.d.ts.map +1 -1
  149. package/dist/textToParticle/react/scrollFadeIn/index.d.ts +0 -1
  150. package/dist/textToParticle/react/scrollFadeIn/index.d.ts.map +1 -1
  151. package/dist/typing/core/index.d.ts +0 -1
  152. package/dist/typing/core/index.d.ts.map +1 -1
  153. package/dist/typing/core/scrollFadeIn/index.d.ts +4 -11
  154. package/dist/typing/core/scrollFadeIn/index.d.ts.map +1 -1
  155. package/dist/typing/core/typing/index.d.ts +2 -0
  156. package/dist/typing/core/typing/index.d.ts.map +1 -1
  157. package/dist/typing/core/utils/visibilityManager.d.ts +1 -0
  158. package/dist/typing/core/utils/visibilityManager.d.ts.map +1 -1
  159. package/dist/typing/index.cjs +1 -1
  160. package/dist/typing/index.d.ts +0 -1
  161. package/dist/typing/index.d.ts.map +1 -1
  162. package/dist/typing/index.mjs +1 -1
  163. package/dist/typing/react/index.d.ts +0 -1
  164. package/dist/typing/react/index.d.ts.map +1 -1
  165. package/dist/typing/react/scrollFadeIn/index.d.ts +0 -1
  166. package/dist/typing/react/scrollFadeIn/index.d.ts.map +1 -1
  167. package/dist/vue/count/index.cjs +1 -1
  168. package/dist/vue/count/index.d.ts +8 -6
  169. package/dist/vue/count/index.mjs +5 -1
  170. package/dist/vue/index.cjs +1 -1
  171. package/dist/vue/index.d.ts +8 -6
  172. package/dist/vue/index.mjs +81 -20
  173. package/dist/vue/scrollFadeIn/index.cjs +1 -1
  174. package/dist/vue/scrollFadeIn/index.d.ts +8 -6
  175. package/dist/vue/scrollFadeIn/index.mjs +28 -17
  176. package/dist/vue/textToParticle/index.cjs +1 -1
  177. package/dist/vue/textToParticle/index.d.ts +8 -6
  178. package/dist/vue/textToParticle/index.mjs +5 -1
  179. package/dist/vue/typing/index.cjs +1 -1
  180. package/dist/vue/typing/index.d.ts +8 -6
  181. package/dist/vue/typing/index.mjs +56 -2
  182. package/package.json +1 -1
@@ -317,6 +317,8 @@ class VisibilityManager {
317
317
  this.options = {
318
318
  threshold: options.threshold ?? 0.1,
319
319
  rootMargin: options.rootMargin ?? "0px",
320
+ root: options.root ?? null,
321
+ // 기본값은 null (viewport 기준)
320
322
  onVisible: options.onVisible,
321
323
  onHidden: options.onHidden
322
324
  };
@@ -354,7 +356,9 @@ class VisibilityManager {
354
356
  },
355
357
  {
356
358
  threshold: this.options.threshold,
357
- rootMargin: this.options.rootMargin
359
+ rootMargin: this.options.rootMargin,
360
+ root: this.options.root || null
361
+ // null이면 viewport 기준, HTMLElement면 해당 요소 기준
358
362
  }
359
363
  );
360
364
  this.intersectionObserver.observe(this.container);
@@ -412,9 +416,7 @@ class VisibilityManager {
412
416
  }
413
417
  }
414
418
  }
415
- const easingFunctions = {
416
- easeOutCubic: (t) => --t * t * t + 1
417
- };
419
+ const defaultEasing = (t) => --t * t * t + 1;
418
420
  class ScrollFadeIn {
419
421
  // 계산된 거리 (px)
420
422
  constructor(container, options = {}) {
@@ -426,14 +428,16 @@ class ScrollFadeIn {
426
428
  direction: options.direction ?? "bottom",
427
429
  distance: options.distance ?? "50px",
428
430
  duration: options.duration ?? 800,
429
- easing: options.easing ?? easingFunctions.easeOutCubic,
430
431
  threshold: options.threshold ?? 0.1,
431
432
  rootMargin: options.rootMargin ?? "0px",
433
+ root: options.root ?? null,
434
+ // 기본값은 null (viewport 기준)
432
435
  triggerOnce: options.triggerOnce ?? false,
433
436
  enabled: options.enabled ?? true,
434
437
  onStart: options.onStart || null,
435
438
  onComplete: options.onComplete || null
436
439
  };
440
+ this.easing = defaultEasing;
437
441
  this.visibilityManager = null;
438
442
  this.animationFrameId = null;
439
443
  this.startTime = null;
@@ -509,15 +513,23 @@ class ScrollFadeIn {
509
513
  this.visibilityManager = new VisibilityManager(this.container, {
510
514
  threshold: this.config.threshold,
511
515
  rootMargin: this.config.rootMargin,
516
+ root: this.config.root,
517
+ // 내부 스크롤 컨테이너 지원
512
518
  onVisible: () => {
513
- if (!this.hasTriggered && this.config.enabled) {
514
- this.hasTriggered = true;
515
- this.start();
519
+ if (this.config.enabled) {
520
+ if (!this.config.triggerOnce || !this.hasTriggered) {
521
+ this.hasTriggered = true;
522
+ this.start();
523
+ }
516
524
  }
517
525
  },
518
526
  onHidden: () => {
519
- if (!this.config.triggerOnce && this.isRunning) {
520
- this.reset();
527
+ if (this.config.enabled) {
528
+ this.stop();
529
+ if (!this.config.triggerOnce) {
530
+ this.hasTriggered = false;
531
+ }
532
+ this.setInitialPosition();
521
533
  }
522
534
  }
523
535
  });
@@ -537,7 +549,7 @@ class ScrollFadeIn {
537
549
  const currentTime = performance.now();
538
550
  const elapsed = currentTime - (this.startTime || 0);
539
551
  const progress = Math.min(elapsed / this.config.duration, 1);
540
- const easedProgress = this.config.easing(progress);
552
+ const easedProgress = this.easing(progress);
541
553
  const direction = this.config.direction;
542
554
  let translateX = 0;
543
555
  let translateY = 0;
@@ -604,7 +616,6 @@ class ScrollFadeIn {
604
616
  this.config = {
605
617
  ...this.config,
606
618
  ...newConfig,
607
- easing: newConfig.easing ?? this.config.easing,
608
619
  onStart: newConfig.onStart ?? this.config.onStart,
609
620
  onComplete: newConfig.onComplete ?? this.config.onComplete
610
621
  };
@@ -612,7 +623,7 @@ class ScrollFadeIn {
612
623
  this.targetDistance = this.parseDistance(this.config.distance);
613
624
  }
614
625
  this.setInitialPosition();
615
- if (newConfig.threshold !== void 0 || newConfig.rootMargin !== void 0) {
626
+ if (newConfig.threshold !== void 0 || newConfig.rootMargin !== void 0 || newConfig.root !== void 0) {
616
627
  if (this.visibilityManager) {
617
628
  this.visibilityManager.destroy();
618
629
  this.visibilityManager = null;
@@ -740,9 +751,9 @@ function instance_1($$self, $$props, $$invalidate) {
740
751
  let { direction = "bottom" } = $$props;
741
752
  let { distance = "50px" } = $$props;
742
753
  let { duration = 800 } = $$props;
743
- let { easing = (t) => t } = $$props;
744
754
  let { threshold = 0.1 } = $$props;
745
755
  let { rootMargin = "0px" } = $$props;
756
+ let { root = null } = $$props;
746
757
  let { triggerOnce = false } = $$props;
747
758
  let { enabled = true } = $$props;
748
759
  let { className = "" } = $$props;
@@ -756,9 +767,9 @@ function instance_1($$self, $$props, $$invalidate) {
756
767
  direction,
757
768
  distance,
758
769
  duration,
759
- easing,
760
770
  threshold,
761
771
  rootMargin,
772
+ root,
762
773
  triggerOnce,
763
774
  enabled,
764
775
  onStart: () => {
@@ -812,9 +823,9 @@ function instance_1($$self, $$props, $$invalidate) {
812
823
  if ("direction" in $$props2) $$invalidate(3, direction = $$props2.direction);
813
824
  if ("distance" in $$props2) $$invalidate(4, distance = $$props2.distance);
814
825
  if ("duration" in $$props2) $$invalidate(5, duration = $$props2.duration);
815
- if ("easing" in $$props2) $$invalidate(6, easing = $$props2.easing);
816
- if ("threshold" in $$props2) $$invalidate(7, threshold = $$props2.threshold);
817
- if ("rootMargin" in $$props2) $$invalidate(8, rootMargin = $$props2.rootMargin);
826
+ if ("threshold" in $$props2) $$invalidate(6, threshold = $$props2.threshold);
827
+ if ("rootMargin" in $$props2) $$invalidate(7, rootMargin = $$props2.rootMargin);
828
+ if ("root" in $$props2) $$invalidate(8, root = $$props2.root);
818
829
  if ("triggerOnce" in $$props2) $$invalidate(9, triggerOnce = $$props2.triggerOnce);
819
830
  if ("enabled" in $$props2) $$invalidate(10, enabled = $$props2.enabled);
820
831
  if ("className" in $$props2) $$invalidate(0, className = $$props2.className);
@@ -822,7 +833,7 @@ function instance_1($$self, $$props, $$invalidate) {
822
833
  if ("$$scope" in $$props2) $$invalidate(17, $$scope = $$props2.$$scope);
823
834
  };
824
835
  $$self.$$.update = () => {
825
- if ($$self.$$.dirty & /*instance, direction, distance, duration, easing, threshold, rootMargin, triggerOnce, enabled*/
836
+ if ($$self.$$.dirty & /*instance, direction, distance, duration, threshold, rootMargin, root, triggerOnce, enabled*/
826
837
  67576) {
827
838
  {
828
839
  if (instance) {
@@ -830,9 +841,9 @@ function instance_1($$self, $$props, $$invalidate) {
830
841
  direction,
831
842
  distance,
832
843
  duration,
833
- easing,
834
844
  threshold,
835
845
  rootMargin,
846
+ root,
836
847
  triggerOnce,
837
848
  enabled,
838
849
  onStart: () => {
@@ -853,9 +864,9 @@ function instance_1($$self, $$props, $$invalidate) {
853
864
  direction,
854
865
  distance,
855
866
  duration,
856
- easing,
857
867
  threshold,
858
868
  rootMargin,
869
+ root,
859
870
  triggerOnce,
860
871
  enabled,
861
872
  start,
@@ -876,9 +887,9 @@ class ScrollFadeIn_1 extends SvelteComponent {
876
887
  direction: 3,
877
888
  distance: 4,
878
889
  duration: 5,
879
- easing: 6,
880
- threshold: 7,
881
- rootMargin: 8,
890
+ threshold: 6,
891
+ rootMargin: 7,
892
+ root: 8,
882
893
  triggerOnce: 9,
883
894
  enabled: 10,
884
895
  className: 0,
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty,e=(e,i,n)=>((e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n)(e,"symbol"!=typeof i?i+"":i,n);const i=require("svelte");function n(){}function s(t){return t()}function o(){return Object.create(null)}function h(t){t.forEach(s)}function a(t){return"function"==typeof t}function r(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function l(t){t.parentNode&&t.parentNode.removeChild(t)}function c(t,e,i){null==i?t.removeAttribute(e):t.getAttribute(e)!==i&&t.setAttribute(e,i)}let d;function u(t){d=t}const f=[],p=[];let g=[];const m=[],v=Promise.resolve();let y=!1;function x(t){g.push(t)}const b=new Set;let w=0;function M(){if(0!==w)return;const t=d;do{try{for(;w<f.length;){const t=f[w];w++,u(t),$(t.$$)}}catch(e){throw f.length=0,w=0,e}for(u(null),f.length=0,w=0;p.length;)p.pop()();for(let t=0;t<g.length;t+=1){const e=g[t];b.has(e)||(b.add(e),e())}g.length=0}while(f.length);for(;m.length;)m.pop()();y=!1,b.clear(),u(t)}function $(t){if(null!==t.fragment){t.update(),h(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(x)}}const C=new Set;function R(t,e){const i=t.$$;null!==i.fragment&&(!function(t){const e=[],i=[];g.forEach(n=>-1===t.indexOf(n)?e.push(n):i.push(n)),i.forEach(t=>t()),g=e}(i.after_update),h(i.on_destroy),i.fragment&&i.fragment.d(e),i.on_destroy=i.fragment=null,i.ctx=[])}function P(t,e){-1===t.$$.dirty[0]&&(f.push(t),y||(y=!0,v.then(M)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function S(t,e,i,r,c,f,p=null,g=[-1]){const m=d;u(t);const v=t.$$={fragment:null,ctx:[],props:f,update:n,not_equal:c,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(m?m.$$.context:[])),callbacks:o(),dirty:g,skip_bound:!1,root:e.target||m.$$.root};p&&p(v.root);let y=!1;if(v.ctx=i?i(t,e.props||{},(e,i,...n)=>{const s=n.length?n[0]:i;return v.ctx&&c(v.ctx[e],v.ctx[e]=s)&&(!v.skip_bound&&v.bound[e]&&v.bound[e](s),y&&P(t,e)),i}):[],v.update(),y=!0,h(v.before_update),v.fragment=!!r&&r(v.ctx),e.target){if(e.hydrate){const t=($=e.target,Array.from($.childNodes));v.fragment&&v.fragment.l(t),t.forEach(l)}else v.fragment&&v.fragment.c();e.intro&&((b=t.$$.fragment)&&b.i&&(C.delete(b),b.i(w))),function(t,e,i){const{fragment:n,after_update:o}=t.$$;n&&n.m(e,i),x(()=>{const e=t.$$.on_mount.map(s).filter(a);t.$$.on_destroy?t.$$.on_destroy.push(...e):h(e),t.$$.on_mount=[]}),o.forEach(x)}(t,e.target,e.anchor),M()}var b,w,$;u(m)}class H{constructor(){e(this,"$$"),e(this,"$$set")}$destroy(){R(this,1),this.$destroy=n}$on(t,e){if(!a(e))return n;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");class _{constructor(t,e={}){this.container=t,this.options={threshold:e.threshold??.1,rootMargin:e.rootMargin??"0px",onVisible:e.onVisible,onHidden:e.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const e of t)e.target===this.container&&(e.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function z(t,e){let i=null;return function(...n){null!==i&&clearTimeout(i),i=setTimeout(()=>{i=null,t.apply(this,n)},e)}}class E{constructor(t,e={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={text:e.text||"mason effect",densityStep:e.densityStep??2,maxParticles:e.maxParticles??3200,pointSize:e.pointSize??.5,ease:e.ease??.05,repelRadius:e.repelRadius??150,repelStrength:e.repelStrength??1,particleColor:e.particleColor||"#fff",fontFamily:e.fontFamily||"Inter, system-ui, Arial",fontSize:e.fontSize||null,width:e.width||null,height:e.height||null,devicePixelRatio:e.devicePixelRatio??null,onReady:e.onReady||null,onUpdate:e.onUpdate||null},this.canvas=document.createElement("canvas");const i=this.canvas.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("Canvas context not available");this.ctx=i,this.container.appendChild(this.canvas),this.canvas.style.display="block",this.offCanvas=document.createElement("canvas");const n=this.offCanvas.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("Offscreen canvas context not available");this.offCtx=n,this.W=0,this.H=0,this.DPR=this.config.devicePixelRatio||Math.min(window.devicePixelRatio||1,1.8),this.particles=[],this.mouse={x:0,y:0,down:!1},this.animationId=null,this.isRunning=!1,this.visibilityManager=null,this.debounceDelay=e.debounceDelay??150;const s=this.handleResize.bind(this);this.handleResize=z(s,this.debounceDelay),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this._debouncedMorph=z(this._morphInternal.bind(this),this.debounceDelay),this._debouncedUpdateConfig=z(this._updateConfigInternal.bind(this),this.debounceDelay),this.init()}init(){this.resize(),this.setupEventListeners(),this.setupVisibilityManager(),this.config.onReady&&this.config.onReady(this)}setupVisibilityManager(){this.visibilityManager=new _(this.container,{threshold:.1,onVisible:()=>{this.start()},onHidden:()=>{this.stop()}})}resize(){const t=this.container.getBoundingClientRect(),e=this.config.width||t.width||this.container.clientWidth||window.innerWidth,i=this.config.height||t.height||this.container.clientHeight||.7*window.innerHeight;if(e<=0||i<=0)return;this.W=Math.floor(e*this.DPR),this.H=Math.floor(i*this.DPR);const n=4096;if(this.W>n||this.H>n){const t=Math.min(n/this.W,n/this.H);this.W=Math.floor(this.W*t),this.H=Math.floor(this.H*t),this.DPR=this.DPR*t}this.canvas.width=this.W,this.canvas.height=this.H,this.canvas.style.width=e+"px",this.canvas.style.height=i+"px",this.W>0&&this.H>0&&(this.buildTargets(),this.particles.length||this.initParticles())}measureTextFit(t,e,i,n){this.offCtx.font=`400 ${t}px ${this.config.fontFamily}`;const s=e.split("\n"),o=t,h=.1*t,a=.05*t;let r=0;for(const c of s){if(0===c.length)continue;const t=this.offCtx.measureText(c).width+a*(c.length>0?c.length-1:0);r=Math.max(r,t)}const l=s.length>0?o*s.length+h*(s.length-1):o;return{width:r,height:l,fits:r<=i&&l<=n}}findOptimalFontSize(t,e,i,n){if(this.measureTextFit(n,t,e,i).fits)return n;if(n<=12)return 12;let s=12,o=n,h=12;for(;s<=o;){const n=Math.floor((s+o)/2);this.measureTextFit(n,t,e,i).fits?(h=n,s=n+1):o=n-1}return h}buildTargets(){if(this.W<=0||this.H<=0)return;const t=this.config.text;this.offCanvas.width=this.W,this.offCanvas.height=this.H,this.offCtx.clearRect(0,0,this.offCanvas.width,this.offCanvas.height);const e=Math.min(this.W,this.H),i=this.config.fontSize||Math.max(80,Math.floor(.18*e)),n=this.W-80,s=this.H-80,o=this.findOptimalFontSize(t,n,s,i);this.offCtx.fillStyle="#ffffff",this.offCtx.textAlign="center",this.offCtx.textBaseline="middle",this.offCtx.font=`400 ${o}px ${this.config.fontFamily}`;const h=t.split("\n"),a=o,r=.1*o,l=.05*o,c=h.length>0?a*h.length+r*(h.length-1):a;let d=this.H/2-c/2+a/2;for(const g of h){if(0===g.length){d+=a+r;continue}const t=g.split(""),e=this.offCtx.measureText(g).width+l*(t.length>0?t.length-1:0);let i=this.W/2-e/2;for(const n of t)this.offCtx.fillText(n,i+this.offCtx.measureText(n).width/2,d),i+=this.offCtx.measureText(n).width+l;d+=a+r}const u=Math.max(2,this.config.densityStep),f=this.offCtx.getImageData(0,0,this.W,this.H).data,p=[];for(let g=0;g<this.H;g+=u)for(let t=0;t<this.W;t+=u){const e=4*(g*this.W+t);f[e]+f[e+1]+f[e+2]>600&&p.push({x:t,y:g})}for(;p.length>this.config.maxParticles;)p.splice(Math.floor(Math.random()*p.length),1);if(this.particles.length<p.length){const t=p.length-this.particles.length;for(let e=0;e<t;e++)this.particles.push(this.makeParticle())}else this.particles.length>p.length&&(this.particles.length=p.length);for(let g=0;g<this.particles.length;g++){const t=this.particles[g],e=p[g];t.tx=e.x,t.ty=e.y}}makeParticle(){const t=Math.random()*this.W,e=Math.random()*this.H;return{x:t,y:e,vx:0,vy:0,tx:t,ty:e,initialX:t,initialY:e,j:Math.random()*Math.PI*2}}initParticles(){for(const t of this.particles){const e=Math.random()*this.W,i=Math.random()*this.H;t.x=e,t.y=i,t.vx=t.vy=0,t.initialX=e,t.initialY=i}}scatter(){for(const t of this.particles)void 0!==t.initialX&&void 0!==t.initialY?(t.tx=t.initialX,t.ty=t.initialY):(t.initialX=t.x,t.initialY=t.y,t.tx=t.initialX,t.ty=t.initialY)}morph(t){this._debouncedMorph(t)}_morphInternal(t){if(0!==this.W&&0!==this.H||this.resize(),"string"==typeof t)this.config.text=t,this.buildTargets();else if(t&&"object"==typeof t){const e=void 0!==t.text;this.config={...this.config,...t},e&&this.buildTargets()}else this.buildTargets()}update(){this.ctx.clearRect(0,0,this.W,this.H);for(const n of this.particles){let t=(n.tx-n.x)*this.config.ease,e=(n.ty-n.y)*this.config.ease;if(this.mouse.x||this.mouse.y){const i=n.x-this.mouse.x,s=n.y-this.mouse.y,o=i*i+s*s,h=this.config.repelRadius*this.DPR;if(o<h*h){const n=Math.sqrt(o)+1e-4,a=(this.mouse.down?-1:1)*this.config.repelStrength*(1-n/h);t+=i/n*a*6,e+=s/n*a*6}}n.j+=2,t+=.05*Math.cos(n.j),e+=.05*Math.sin(1.3*n.j),n.vx=(n.vx+t)*Math.random(),n.vy=(n.vy+e)*Math.random(),n.x+=n.vx,n.y+=n.vy}this.ctx.fillStyle=this.config.particleColor;const t=Math.min(this.W,this.H)/this.DPR,e=Math.max(.5,Math.min(2,t/1920)),i=this.config.pointSize*this.DPR*e;for(const n of this.particles)this.ctx.beginPath(),this.ctx.arc(n.x,n.y,i,0,2*Math.PI),this.ctx.fill();this.config.onUpdate&&this.config.onUpdate(this)}animate(){this.isRunning&&(this.update(),this.animationId=requestAnimationFrame(()=>this.animate()))}start(){this.isRunning||(this.isRunning=!0,this.animate())}stop(){this.isRunning=!1,this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null)}setupEventListeners(){window.addEventListener("resize",this.handleResize),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave),this.canvas.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp)}removeEventListeners(){window.removeEventListener("resize",this.handleResize),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave),this.canvas.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}handleResize(){this.resize()}handleMouseMove(t){const e=this.canvas.getBoundingClientRect();this.mouse.x=(t.clientX-e.left)*this.DPR,this.mouse.y=(t.clientY-e.top)*this.DPR}handleMouseLeave(){this.mouse.x=this.mouse.y=0}handleMouseDown(){this.mouse.down=!0}handleMouseUp(){this.mouse.down=!1}updateConfig(t){this._debouncedUpdateConfig(t)}_updateConfigInternal(t){this.config={...this.config,...t},t.text&&this.buildTargets()}destroy(){this.stop(),this.removeEventListeners(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}function V(t){let e;return{c(){var i;i="div",e=document.createElement(i),c(e,"class",t[0]),c(e,"style",t[1])},m(i,n){!function(t,e,i){t.insertBefore(e,i||null)}(i,e,n),t[21](e)},p(t,[i]){1&i&&c(e,"class",t[0]),2&i&&c(e,"style",t[1])},i:n,o:n,d(i){i&&l(e),t[21](null)}}}function D(t,e,n){let{text:s="mason effect"}=e,{densityStep:o=2}=e,{maxParticles:h=3200}=e,{pointSize:a=.5}=e,{ease:r=.05}=e,{repelRadius:l=150}=e,{repelStrength:c=1}=e,{particleColor:d="#fff"}=e,{fontFamily:u="Inter, system-ui, Arial"}=e,{fontSize:f=null}=e,{width:g=null}=e,{height:m=null}=e,{devicePixelRatio:v=null}=e,{className:y=""}=e,{style:x={}}=e;const b=i.createEventDispatcher();let w,M=null;return i.onMount(()=>{if(!w)return;n(20,M=new E(w,{text:s,densityStep:o,maxParticles:h,pointSize:a,ease:r,repelRadius:l,repelStrength:c,particleColor:d,fontFamily:u,fontSize:f,width:g,height:m,devicePixelRatio:v,onReady:t=>{b("ready",t)},onUpdate:t=>{b("update",t)}}))}),i.onDestroy(()=>{M&&(M.destroy(),n(20,M=null))}),t.$$set=t=>{"text"in t&&n(3,s=t.text),"densityStep"in t&&n(4,o=t.densityStep),"maxParticles"in t&&n(5,h=t.maxParticles),"pointSize"in t&&n(6,a=t.pointSize),"ease"in t&&n(7,r=t.ease),"repelRadius"in t&&n(8,l=t.repelRadius),"repelStrength"in t&&n(9,c=t.repelStrength),"particleColor"in t&&n(10,d=t.particleColor),"fontFamily"in t&&n(11,u=t.fontFamily),"fontSize"in t&&n(12,f=t.fontSize),"width"in t&&n(13,g=t.width),"height"in t&&n(14,m=t.height),"devicePixelRatio"in t&&n(15,v=t.devicePixelRatio),"className"in t&&n(0,y=t.className),"style"in t&&n(1,x=t.style)},t.$$.update=()=>{1114104&t.$$.dirty&&M&&M.updateConfig({text:s,densityStep:o,maxParticles:h,pointSize:a,ease:r,repelRadius:l,repelStrength:c,particleColor:d,fontFamily:u,fontSize:f,width:g,height:m,devicePixelRatio:v})},[y,x,w,s,o,h,a,r,l,c,d,u,f,g,m,v,function(t){M&&M.morph(t)},function(){M&&M.scatter()},function(t){M&&M.updateConfig(t)},function(){M&&(M.destroy(),n(20,M=null))},M,function(t){p[t?"unshift":"push"](()=>{w=t,n(2,w)})}]}module.exports=class extends H{constructor(t){super(),S(this,t,D,V,r,{text:3,densityStep:4,maxParticles:5,pointSize:6,ease:7,repelRadius:8,repelStrength:9,particleColor:10,fontFamily:11,fontSize:12,width:13,height:14,devicePixelRatio:15,className:0,style:1,morph:16,scatter:17,updateConfig:18,destroy:19})}get morph(){return this.$$.ctx[16]}get scatter(){return this.$$.ctx[17]}get updateConfig(){return this.$$.ctx[18]}get destroy(){return this.$$.ctx[19]}};
1
+ "use strict";var t=Object.defineProperty,i=(i,e,n)=>((i,e,n)=>e in i?t(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n)(i,"symbol"!=typeof e?e+"":e,n);const e=require("svelte");function n(){}function s(t){return t()}function o(){return Object.create(null)}function h(t){t.forEach(s)}function a(t){return"function"==typeof t}function r(t,i){return t!=t?i==i:t!==i||t&&"object"==typeof t||"function"==typeof t}function l(t){t.parentNode&&t.parentNode.removeChild(t)}function c(t,i,e){null==e?t.removeAttribute(i):t.getAttribute(i)!==e&&t.setAttribute(i,e)}let d;function u(t){d=t}const f=[],p=[];let g=[];const m=[],v=Promise.resolve();let y=!1;function x(t){g.push(t)}const b=new Set;let w=0;function M(){if(0!==w)return;const t=d;do{try{for(;w<f.length;){const t=f[w];w++,u(t),$(t.$$)}}catch(i){throw f.length=0,w=0,i}for(u(null),f.length=0,w=0;p.length;)p.pop()();for(let t=0;t<g.length;t+=1){const i=g[t];b.has(i)||(b.add(i),i())}g.length=0}while(f.length);for(;m.length;)m.pop()();y=!1,b.clear(),u(t)}function $(t){if(null!==t.fragment){t.update(),h(t.before_update);const i=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,i),t.after_update.forEach(x)}}const C=new Set;function R(t,i){const e=t.$$;null!==e.fragment&&(!function(t){const i=[],e=[];g.forEach(n=>-1===t.indexOf(n)?i.push(n):e.push(n)),e.forEach(t=>t()),g=i}(e.after_update),h(e.on_destroy),e.fragment&&e.fragment.d(i),e.on_destroy=e.fragment=null,e.ctx=[])}function P(t,i){-1===t.$$.dirty[0]&&(f.push(t),y||(y=!0,v.then(M)),t.$$.dirty.fill(0)),t.$$.dirty[i/31|0]|=1<<i%31}function S(t,i,e,r,c,f,p=null,g=[-1]){const m=d;u(t);const v=t.$$={fragment:null,ctx:[],props:f,update:n,not_equal:c,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(i.context||(m?m.$$.context:[])),callbacks:o(),dirty:g,skip_bound:!1,root:i.target||m.$$.root};p&&p(v.root);let y=!1;if(v.ctx=e?e(t,i.props||{},(i,e,...n)=>{const s=n.length?n[0]:e;return v.ctx&&c(v.ctx[i],v.ctx[i]=s)&&(!v.skip_bound&&v.bound[i]&&v.bound[i](s),y&&P(t,i)),e}):[],v.update(),y=!0,h(v.before_update),v.fragment=!!r&&r(v.ctx),i.target){if(i.hydrate){const t=($=i.target,Array.from($.childNodes));v.fragment&&v.fragment.l(t),t.forEach(l)}else v.fragment&&v.fragment.c();i.intro&&((b=t.$$.fragment)&&b.i&&(C.delete(b),b.i(w))),function(t,i,e){const{fragment:n,after_update:o}=t.$$;n&&n.m(i,e),x(()=>{const i=t.$$.on_mount.map(s).filter(a);t.$$.on_destroy?t.$$.on_destroy.push(...i):h(i),t.$$.on_mount=[]}),o.forEach(x)}(t,i.target,i.anchor),M()}var b,w,$;u(m)}class H{constructor(){i(this,"$$"),i(this,"$$set")}$destroy(){R(this,1),this.$destroy=n}$on(t,i){if(!a(i))return n;const e=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return e.push(i),()=>{const t=e.indexOf(i);-1!==t&&e.splice(t,1)}}$set(t){var i;this.$$set&&(i=t,0!==Object.keys(i).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");class _{constructor(t,i={}){this.container=t,this.options={threshold:i.threshold??.1,rootMargin:i.rootMargin??"0px",root:i.root??null,onVisible:i.onVisible,onHidden:i.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const i of t)i.target===this.container&&(i.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin,root:this.options.root||null}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function z(t,i){let e=null;return function(...n){null!==e&&clearTimeout(e),e=setTimeout(()=>{e=null,t.apply(this,n)},i)}}class E{constructor(t,i={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={text:i.text||"mason effect",densityStep:i.densityStep??2,maxParticles:i.maxParticles??3200,pointSize:i.pointSize??.5,ease:i.ease??.05,repelRadius:i.repelRadius??150,repelStrength:i.repelStrength??1,particleColor:i.particleColor||"#fff",fontFamily:i.fontFamily||"Inter, system-ui, Arial",fontSize:i.fontSize||null,width:i.width||null,height:i.height||null,devicePixelRatio:i.devicePixelRatio??null,onReady:i.onReady||null,onUpdate:i.onUpdate||null},this.canvas=document.createElement("canvas");const e=this.canvas.getContext("2d",{willReadFrequently:!0});if(!e)throw new Error("Canvas context not available");this.ctx=e,this.container.appendChild(this.canvas),this.canvas.style.display="block",this.offCanvas=document.createElement("canvas");const n=this.offCanvas.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("Offscreen canvas context not available");this.offCtx=n,this.W=0,this.H=0,this.DPR=this.config.devicePixelRatio||Math.min(window.devicePixelRatio||1,1.8),this.particles=[],this.mouse={x:0,y:0,down:!1},this.animationId=null,this.isRunning=!1,this.visibilityManager=null,this.debounceDelay=i.debounceDelay??150;const s=this.handleResize.bind(this);this.handleResize=z(s,this.debounceDelay),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this._debouncedMorph=z(this._morphInternal.bind(this),this.debounceDelay),this._debouncedUpdateConfig=z(this._updateConfigInternal.bind(this),this.debounceDelay),this.init()}init(){this.resize(),this.setupEventListeners(),this.setupVisibilityManager(),this.config.onReady&&this.config.onReady(this)}setupVisibilityManager(){this.visibilityManager=new _(this.container,{threshold:.1,onVisible:()=>{this.start()},onHidden:()=>{this.stop()}})}resize(){const t=this.container.getBoundingClientRect(),i=this.config.width||t.width||this.container.clientWidth||window.innerWidth,e=this.config.height||t.height||this.container.clientHeight||.7*window.innerHeight;if(i<=0||e<=0)return;this.W=Math.floor(i*this.DPR),this.H=Math.floor(e*this.DPR);const n=4096;if(this.W>n||this.H>n){const t=Math.min(n/this.W,n/this.H);this.W=Math.floor(this.W*t),this.H=Math.floor(this.H*t),this.DPR=this.DPR*t}this.canvas.width=this.W,this.canvas.height=this.H,this.canvas.style.width=i+"px",this.canvas.style.height=e+"px",this.W>0&&this.H>0&&(this.buildTargets(),this.particles.length||this.initParticles())}measureTextFit(t,i,e,n){this.offCtx.font=`400 ${t}px ${this.config.fontFamily}`;const s=i.split("\n"),o=t,h=.1*t,a=.05*t;let r=0;for(const c of s){if(0===c.length)continue;const t=this.offCtx.measureText(c).width+a*(c.length>0?c.length-1:0);r=Math.max(r,t)}const l=s.length>0?o*s.length+h*(s.length-1):o;return{width:r,height:l,fits:r<=e&&l<=n}}findOptimalFontSize(t,i,e,n){if(this.measureTextFit(n,t,i,e).fits)return n;if(n<=12)return 12;let s=12,o=n,h=12;for(;s<=o;){const n=Math.floor((s+o)/2);this.measureTextFit(n,t,i,e).fits?(h=n,s=n+1):o=n-1}return h}buildTargets(){if(this.W<=0||this.H<=0)return;const t=this.config.text;this.offCanvas.width=this.W,this.offCanvas.height=this.H,this.offCtx.clearRect(0,0,this.offCanvas.width,this.offCanvas.height);const i=Math.min(this.W,this.H),e=this.config.fontSize||Math.max(80,Math.floor(.18*i)),n=this.W-80,s=this.H-80,o=this.findOptimalFontSize(t,n,s,e);this.offCtx.fillStyle="#ffffff",this.offCtx.textAlign="center",this.offCtx.textBaseline="middle",this.offCtx.font=`400 ${o}px ${this.config.fontFamily}`;const h=t.split("\n"),a=o,r=.1*o,l=.05*o,c=h.length>0?a*h.length+r*(h.length-1):a;let d=this.H/2-c/2+a/2;for(const g of h){if(0===g.length){d+=a+r;continue}const t=g.split(""),i=this.offCtx.measureText(g).width+l*(t.length>0?t.length-1:0);let e=this.W/2-i/2;for(const n of t)this.offCtx.fillText(n,e+this.offCtx.measureText(n).width/2,d),e+=this.offCtx.measureText(n).width+l;d+=a+r}const u=Math.max(2,this.config.densityStep),f=this.offCtx.getImageData(0,0,this.W,this.H).data,p=[];for(let g=0;g<this.H;g+=u)for(let t=0;t<this.W;t+=u){const i=4*(g*this.W+t);f[i]+f[i+1]+f[i+2]>600&&p.push({x:t,y:g})}for(;p.length>this.config.maxParticles;)p.splice(Math.floor(Math.random()*p.length),1);if(this.particles.length<p.length){const t=p.length-this.particles.length;for(let i=0;i<t;i++)this.particles.push(this.makeParticle())}else this.particles.length>p.length&&(this.particles.length=p.length);for(let g=0;g<this.particles.length;g++){const t=this.particles[g],i=p[g];t.tx=i.x,t.ty=i.y}}makeParticle(){const t=Math.random()*this.W,i=Math.random()*this.H;return{x:t,y:i,vx:0,vy:0,tx:t,ty:i,initialX:t,initialY:i,j:Math.random()*Math.PI*2}}initParticles(){for(const t of this.particles){const i=Math.random()*this.W,e=Math.random()*this.H;t.x=i,t.y=e,t.vx=t.vy=0,t.initialX=i,t.initialY=e}}scatter(){for(const t of this.particles)void 0!==t.initialX&&void 0!==t.initialY?(t.tx=t.initialX,t.ty=t.initialY):(t.initialX=t.x,t.initialY=t.y,t.tx=t.initialX,t.ty=t.initialY)}morph(t){this._debouncedMorph(t)}_morphInternal(t){if(0!==this.W&&0!==this.H||this.resize(),"string"==typeof t)this.config.text=t,this.buildTargets();else if(t&&"object"==typeof t){const i=void 0!==t.text;this.config={...this.config,...t},i&&this.buildTargets()}else this.buildTargets()}update(){this.ctx.clearRect(0,0,this.W,this.H);for(const n of this.particles){let t=(n.tx-n.x)*this.config.ease,i=(n.ty-n.y)*this.config.ease;if(this.mouse.x||this.mouse.y){const e=n.x-this.mouse.x,s=n.y-this.mouse.y,o=e*e+s*s,h=this.config.repelRadius*this.DPR;if(o<h*h){const n=Math.sqrt(o)+1e-4,a=(this.mouse.down?-1:1)*this.config.repelStrength*(1-n/h);t+=e/n*a*6,i+=s/n*a*6}}n.j+=2,t+=.05*Math.cos(n.j),i+=.05*Math.sin(1.3*n.j),n.vx=(n.vx+t)*Math.random(),n.vy=(n.vy+i)*Math.random(),n.x+=n.vx,n.y+=n.vy}this.ctx.fillStyle=this.config.particleColor;const t=Math.min(this.W,this.H)/this.DPR,i=Math.max(.5,Math.min(2,t/1920)),e=this.config.pointSize*this.DPR*i;for(const n of this.particles)this.ctx.beginPath(),this.ctx.arc(n.x,n.y,e,0,2*Math.PI),this.ctx.fill();this.config.onUpdate&&this.config.onUpdate(this)}animate(){this.isRunning&&(this.update(),this.animationId=requestAnimationFrame(()=>this.animate()))}start(){this.isRunning||(this.isRunning=!0,this.animate())}stop(){this.isRunning=!1,this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null)}setupEventListeners(){window.addEventListener("resize",this.handleResize),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave),this.canvas.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp)}removeEventListeners(){window.removeEventListener("resize",this.handleResize),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave),this.canvas.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}handleResize(){this.resize()}handleMouseMove(t){const i=this.canvas.getBoundingClientRect();this.mouse.x=(t.clientX-i.left)*this.DPR,this.mouse.y=(t.clientY-i.top)*this.DPR}handleMouseLeave(){this.mouse.x=this.mouse.y=0}handleMouseDown(){this.mouse.down=!0}handleMouseUp(){this.mouse.down=!1}updateConfig(t){this._debouncedUpdateConfig(t)}_updateConfigInternal(t){this.config={...this.config,...t},t.text&&this.buildTargets()}destroy(){this.stop(),this.removeEventListeners(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}function V(t){let i;return{c(){var e;e="div",i=document.createElement(e),c(i,"class",t[0]),c(i,"style",t[1])},m(e,n){!function(t,i,e){t.insertBefore(i,e||null)}(e,i,n),t[21](i)},p(t,[e]){1&e&&c(i,"class",t[0]),2&e&&c(i,"style",t[1])},i:n,o:n,d(e){e&&l(i),t[21](null)}}}function D(t,i,n){let{text:s="mason effect"}=i,{densityStep:o=2}=i,{maxParticles:h=3200}=i,{pointSize:a=.5}=i,{ease:r=.05}=i,{repelRadius:l=150}=i,{repelStrength:c=1}=i,{particleColor:d="#fff"}=i,{fontFamily:u="Inter, system-ui, Arial"}=i,{fontSize:f=null}=i,{width:g=null}=i,{height:m=null}=i,{devicePixelRatio:v=null}=i,{className:y=""}=i,{style:x={}}=i;const b=e.createEventDispatcher();let w,M=null;return e.onMount(()=>{if(!w)return;n(20,M=new E(w,{text:s,densityStep:o,maxParticles:h,pointSize:a,ease:r,repelRadius:l,repelStrength:c,particleColor:d,fontFamily:u,fontSize:f,width:g,height:m,devicePixelRatio:v,onReady:t=>{b("ready",t)},onUpdate:t=>{b("update",t)}}))}),e.onDestroy(()=>{M&&(M.destroy(),n(20,M=null))}),t.$$set=t=>{"text"in t&&n(3,s=t.text),"densityStep"in t&&n(4,o=t.densityStep),"maxParticles"in t&&n(5,h=t.maxParticles),"pointSize"in t&&n(6,a=t.pointSize),"ease"in t&&n(7,r=t.ease),"repelRadius"in t&&n(8,l=t.repelRadius),"repelStrength"in t&&n(9,c=t.repelStrength),"particleColor"in t&&n(10,d=t.particleColor),"fontFamily"in t&&n(11,u=t.fontFamily),"fontSize"in t&&n(12,f=t.fontSize),"width"in t&&n(13,g=t.width),"height"in t&&n(14,m=t.height),"devicePixelRatio"in t&&n(15,v=t.devicePixelRatio),"className"in t&&n(0,y=t.className),"style"in t&&n(1,x=t.style)},t.$$.update=()=>{1114104&t.$$.dirty&&M&&M.updateConfig({text:s,densityStep:o,maxParticles:h,pointSize:a,ease:r,repelRadius:l,repelStrength:c,particleColor:d,fontFamily:u,fontSize:f,width:g,height:m,devicePixelRatio:v})},[y,x,w,s,o,h,a,r,l,c,d,u,f,g,m,v,function(t){M&&M.morph(t)},function(){M&&M.scatter()},function(t){M&&M.updateConfig(t)},function(){M&&(M.destroy(),n(20,M=null))},M,function(t){p[t?"unshift":"push"](()=>{w=t,n(2,w)})}]}module.exports=class extends H{constructor(t){super(),S(this,t,D,V,r,{text:3,densityStep:4,maxParticles:5,pointSize:6,ease:7,repelRadius:8,repelStrength:9,particleColor:10,fontFamily:11,fontSize:12,width:13,height:14,devicePixelRatio:15,className:0,style:1,morph:16,scatter:17,updateConfig:18,destroy:19})}get morph(){return this.$$.ctx[16]}get scatter(){return this.$$.ctx[17]}get updateConfig(){return this.$$.ctx[18]}get destroy(){return this.$$.ctx[19]}};
@@ -36,15 +36,13 @@ export declare interface CountOptions {
36
36
  onComplete?: () => void;
37
37
  }
38
38
 
39
- declare const easingFunctions: {
39
+ export declare const easingFunctions: {
40
40
  linear: (t: number) => number;
41
41
  easeInQuad: (t: number) => number;
42
42
  easeOutQuad: (t: number) => number;
43
43
  easeInOutQuad: (t: number) => number;
44
44
  easeOutCubic: (t: number) => number;
45
45
  };
46
- export { easingFunctions }
47
- export { easingFunctions as scrollFadeInEasingFunctions }
48
46
 
49
47
  export declare interface Particle {
50
48
  x: number;
@@ -60,11 +58,12 @@ export declare interface Particle {
60
58
 
61
59
  export declare class ScrollFadeIn {
62
60
  container: HTMLElement;
63
- config: Required<Omit<ScrollFadeInOptions, 'onStart' | 'onComplete' | 'easing'>> & {
64
- easing: (t: number) => number;
61
+ config: Required<Omit<ScrollFadeInOptions, 'onStart' | 'onComplete' | 'root'>> & {
62
+ root: HTMLElement | null;
65
63
  onStart: ScrollFadeInOptions['onStart'];
66
64
  onComplete: ScrollFadeInOptions['onComplete'];
67
65
  };
66
+ private easing;
68
67
  visibilityManager: VisibilityManager | null;
69
68
  animationFrameId: number | null;
70
69
  startTime: number | null;
@@ -90,9 +89,9 @@ export declare interface ScrollFadeInOptions {
90
89
  direction?: 'top' | 'right' | 'bottom' | 'left';
91
90
  distance?: string;
92
91
  duration?: number;
93
- easing?: (t: number) => number;
94
92
  threshold?: number;
95
93
  rootMargin?: string;
94
+ root?: HTMLElement | null;
96
95
  triggerOnce?: boolean;
97
96
  enabled?: boolean;
98
97
  onStart?: () => void;
@@ -209,6 +208,7 @@ declare class TextToParticle {
209
208
  originalText: string;
210
209
  constructor(container: HTMLElement | string, options: TypingOptions);
211
210
  init(): void;
211
+ private injectStyles;
212
212
  setupVisibilityManager(): void;
213
213
  private buildTextFromUnits;
214
214
  start(): void;
@@ -216,6 +216,7 @@ declare class TextToParticle {
216
216
  stop(): void;
217
217
  reset(): void;
218
218
  updateDisplay(text: string): void;
219
+ private escapeHtml;
219
220
  setText(newText: string): void;
220
221
  destroy(): void;
221
222
  }
@@ -265,6 +266,7 @@ declare class TextToParticle {
265
266
  declare interface VisibilityManagerOptions {
266
267
  threshold?: number;
267
268
  rootMargin?: string;
269
+ root?: HTMLElement | null;
268
270
  onVisible?: () => void;
269
271
  onHidden?: () => void;
270
272
  }
@@ -269,6 +269,8 @@ class VisibilityManager {
269
269
  this.options = {
270
270
  threshold: options.threshold ?? 0.1,
271
271
  rootMargin: options.rootMargin ?? "0px",
272
+ root: options.root ?? null,
273
+ // 기본값은 null (viewport 기준)
272
274
  onVisible: options.onVisible,
273
275
  onHidden: options.onHidden
274
276
  };
@@ -306,7 +308,9 @@ class VisibilityManager {
306
308
  },
307
309
  {
308
310
  threshold: this.options.threshold,
309
- rootMargin: this.options.rootMargin
311
+ rootMargin: this.options.rootMargin,
312
+ root: this.options.root || null
313
+ // null이면 viewport 기준, HTMLElement면 해당 요소 기준
310
314
  }
311
315
  );
312
316
  this.intersectionObserver.observe(this.container);
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty,e=(e,i,n)=>((e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n)(e,"symbol"!=typeof i?i+"":i,n);const i=require("svelte");function n(){}function s(t){return t()}function o(){return Object.create(null)}function r(t){t.forEach(s)}function h(t){return"function"==typeof t}function l(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function a(t,e,i){t.$$.on_destroy.push(function(t,...e){if(null==t){for(const t of e)t(void 0);return n}const i=t.subscribe(...e);return i.unsubscribe?()=>i.unsubscribe():i}(e,i))}function u(t){t.parentNode&&t.parentNode.removeChild(t)}function c(t,e,i){null==i?t.removeAttribute(e):t.getAttribute(e)!==i&&t.setAttribute(e,i)}let d;function f(t){d=t}const g=[],p=[];let b=[];const y=[],x=Promise.resolve();let m=!1;function $(t){b.push(t)}const v=new Set;let C=0;function w(){if(0!==C)return;const t=d;do{try{for(;C<g.length;){const t=g[C];C++,f(t),V(t.$$)}}catch(e){throw g.length=0,C=0,e}for(f(null),g.length=0,C=0;p.length;)p.pop()();for(let t=0;t<b.length;t+=1){const e=b[t];v.has(e)||(v.add(e),e())}b.length=0}while(g.length);for(;y.length;)y.pop()();m=!1,v.clear(),f(t)}function V(t){if(null!==t.fragment){t.update(),r(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach($)}}const O=new Set;function _(t,e){const i=t.$$;null!==i.fragment&&(!function(t){const e=[],i=[];b.forEach(n=>-1===t.indexOf(n)?e.push(n):i.push(n)),i.forEach(t=>t()),b=e}(i.after_update),r(i.on_destroy),i.fragment&&i.fragment.d(e),i.on_destroy=i.fragment=null,i.ctx=[])}function T(t,e){-1===t.$$.dirty[0]&&(g.push(t),m||(m=!0,x.then(w)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function M(t,e,i,l,a,c,g=null,p=[-1]){const b=d;f(t);const y=t.$$={fragment:null,ctx:[],props:c,update:n,not_equal:a,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(b?b.$$.context:[])),callbacks:o(),dirty:p,skip_bound:!1,root:e.target||b.$$.root};g&&g(y.root);let x=!1;if(y.ctx=i?i(t,e.props||{},(e,i,...n)=>{const s=n.length?n[0]:i;return y.ctx&&a(y.ctx[e],y.ctx[e]=s)&&(!y.skip_bound&&y.bound[e]&&y.bound[e](s),x&&T(t,e)),i}):[],y.update(),x=!0,r(y.before_update),y.fragment=!!l&&l(y.ctx),e.target){if(e.hydrate){const t=(C=e.target,Array.from(C.childNodes));y.fragment&&y.fragment.l(t),t.forEach(u)}else y.fragment&&y.fragment.c();e.intro&&((m=t.$$.fragment)&&m.i&&(O.delete(m),m.i(v))),function(t,e,i){const{fragment:n,after_update:o}=t.$$;n&&n.m(e,i),$(()=>{const e=t.$$.on_mount.map(s).filter(h);t.$$.on_destroy?t.$$.on_destroy.push(...e):r(e),t.$$.on_mount=[]}),o.forEach($)}(t,e.target,e.anchor),w()}var m,v,C;f(b)}class U{constructor(){e(this,"$$"),e(this,"$$set")}$destroy(){_(this,1),this.$destroy=n}$on(t,e){if(!h(e))return n;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");class H{constructor(t,e={}){this.container=t,this.options={threshold:e.threshold??.1,rootMargin:e.rootMargin??"0px",onVisible:e.onVisible,onHidden:e.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const e of t)e.target===this.container&&(e.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function I(t){const e=t.charCodeAt(0);if(e<44032||e>55203)return[t];const i=e-44032,n=Math.floor(i/588),s=Math.floor(i%588/28),o=i%28,r=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],h=[];return h.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][n]),h.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][s]),o>0&&h.push(r[o]),h}function R(t,e,i){const n=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),s=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(e),o=i?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(i):0;if(-1===n||-1===s)return t+(e||"")+(i||"");const r=44032+21*n*28+28*s+o;return String.fromCharCode(r)}function P(t){const e=[],i=[];for(let n=0;n<t.length;n++){const s=t[n],o=s.charCodeAt(0),r=e.length;if(o>=44032&&o<=55203){const t=I(s);e.push(...t),i.push({start:r,end:e.length,isHangul:!0})}else e.push(s),i.push({start:r,end:e.length,isHangul:!1})}return{units:e,charUnitRanges:i}}class k{constructor(t,e){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=e.text,this.config={text:e.text,speed:e.speed??50,delay:e.delay??0,enabled:e.enabled??!0,threshold:e.threshold??.2,rootMargin:e.rootMargin??"0px 0px -100px 0px",triggerOnce:e.triggerOnce??!1,showCursor:e.showCursor??!0,cursorChar:e.cursorChar??"|",onUpdate:e.onUpdate||null,onComplete:e.onComplete||null};const i=P(this.config.text);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.setupVisibilityManager()}setupVisibilityManager(){this.visibilityManager=new H(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,setTimeout(()=>this.start(),this.config.delay))},onHidden:()=>{}})}buildTextFromUnits(t){if(0===t)return"";let e="";for(let i=0;i<this.charUnitRanges.length;i++){const n=this.charUnitRanges[i];if(n.start>=t)break;const s=Math.min(t-n.start,n.end-n.start);if(s<=0)break;if(n.isHangul){const t=this.textUnits.slice(n.start,n.start+s);1===t.length?e+=t[0]:2===t.length?e+=R(t[0],t[1]):t.length>=3&&(e+=R(t[0],t[1],t[2]))}else s>0&&(e+=this.textUnits[n.start])}return e}start(){this.isRunning||(this.isRunning=!0,this.currentIndex=0,this.displayedText="",this.typeNext())}typeNext(){if(this.currentIndex>=this.textUnits.length)return this.isRunning=!1,this.config.showCursor&&this.updateDisplay(this.originalText),void(this.config.onComplete&&this.config.onComplete());this.displayedText=this.buildTextFromUnits(this.currentIndex+1);let t=this.displayedText;this.config.showCursor&&(t+=this.config.cursorChar),this.updateDisplay(t),this.config.onUpdate&&this.config.onUpdate(this.displayedText),this.currentIndex++,this.timeoutId=setTimeout(()=>{this.typeNext()},this.config.speed)}stop(){this.isRunning=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}reset(){this.stop(),this.currentIndex=0,this.displayedText="",this.hasTriggered=!1,this.updateDisplay("")}updateDisplay(t){this.container.textContent=t}setText(t){this.originalText=t,this.config.text=t;const e=P(t);this.textUnits=e.units,this.charUnitRanges=e.charUnitRanges,this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}function E(t){let e;return{c(){var i;i="div",e=document.createElement(i),c(e,"class",t[1]),c(e,"style",t[2])},m(i,n){!function(t,e,i){t.insertBefore(e,i||null)}(i,e,n),t[8](e)},p:n,i:n,o:n,d(i){i&&u(e),t[8](null)}}}function N(t,e,n){let s,o;a(t,effect,t=>n(10,s=t)),a(t,props,t=>n(11,o=t));let{text:r,speed:h=50,delay:l=0,enabled:u=!0,threshold:c=.2,rootMargin:d="0px 0px -100px 0px",triggerOnce:f=!1,showCursor:g=!0,cursorChar:b="|",className:y="",style:x="",onUpdate:m,onComplete:$}=o(),v=null,C=null;return i.onMount(()=>{if(!v)return;C=new k(v,{text:r,speed:h,delay:l,enabled:u,threshold:c,rootMargin:d,triggerOnce:f,showCursor:g,cursorChar:b,onUpdate:m,onComplete:$})}),i.onDestroy(()=>{C&&(C.destroy(),C=null)}),s(()=>{C&&r!==C.originalText&&C.setText(r)}),[v,y,x,function(){null==C||C.start()},function(){null==C||C.stop()},function(){null==C||C.reset()},function(t){null==C||C.setText(t)},function(){C&&(C.destroy(),C=null)},function(t){p[t?"unshift":"push"](()=>{v=t,n(0,v)})}]}module.exports=class extends U{constructor(t){super(),M(this,t,N,E,l,{start:3,stop:4,reset:5,setText:6,destroy:7})}get start(){return this.$$.ctx[3]}get stop(){return this.$$.ctx[4]}get reset(){return this.$$.ctx[5]}get setText(){return this.$$.ctx[6]}get destroy(){return this.$$.ctx[7]}};
1
+ "use strict";var t=Object.defineProperty,e=(e,i,n)=>((e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n)(e,"symbol"!=typeof i?i+"":i,n);const i=require("svelte");function n(){}function s(t){return t()}function o(){return Object.create(null)}function r(t){t.forEach(s)}function h(t){return"function"==typeof t}function l(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function a(t,e,i){t.$$.on_destroy.push(function(t,...e){if(null==t){for(const t of e)t(void 0);return n}const i=t.subscribe(...e);return i.unsubscribe?()=>i.unsubscribe():i}(e,i))}function c(t){t.parentNode&&t.parentNode.removeChild(t)}function u(t,e,i){null==i?t.removeAttribute(e):t.getAttribute(e)!==i&&t.setAttribute(e,i)}let d;function p(t){d=t}const g=[],f=[];let y=[];const b=[],m=Promise.resolve();let x=!1;function $(t){y.push(t)}const v=new Set;let C=0;function w(){if(0!==C)return;const t=d;do{try{for(;C<g.length;){const t=g[C];C++,p(t),V(t.$$)}}catch(e){throw g.length=0,C=0,e}for(p(null),g.length=0,C=0;f.length;)f.pop()();for(let t=0;t<y.length;t+=1){const e=y[t];v.has(e)||(v.add(e),e())}y.length=0}while(g.length);for(;b.length;)b.pop()();x=!1,v.clear(),p(t)}function V(t){if(null!==t.fragment){t.update(),r(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach($)}}const O=new Set;function T(t,e){const i=t.$$;null!==i.fragment&&(!function(t){const e=[],i=[];y.forEach(n=>-1===t.indexOf(n)?e.push(n):i.push(n)),i.forEach(t=>t()),y=e}(i.after_update),r(i.on_destroy),i.fragment&&i.fragment.d(e),i.on_destroy=i.fragment=null,i.ctx=[])}function _(t,e){-1===t.$$.dirty[0]&&(g.push(t),x||(x=!0,m.then(w)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function H(t,e,i,l,a,u,g=null,f=[-1]){const y=d;p(t);const b=t.$$={fragment:null,ctx:[],props:u,update:n,not_equal:a,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(y?y.$$.context:[])),callbacks:o(),dirty:f,skip_bound:!1,root:e.target||y.$$.root};g&&g(b.root);let m=!1;if(b.ctx=i?i(t,e.props||{},(e,i,...n)=>{const s=n.length?n[0]:i;return b.ctx&&a(b.ctx[e],b.ctx[e]=s)&&(!b.skip_bound&&b.bound[e]&&b.bound[e](s),m&&_(t,e)),i}):[],b.update(),m=!0,r(b.before_update),b.fragment=!!l&&l(b.ctx),e.target){if(e.hydrate){const t=(C=e.target,Array.from(C.childNodes));b.fragment&&b.fragment.l(t),t.forEach(c)}else b.fragment&&b.fragment.c();e.intro&&((x=t.$$.fragment)&&x.i&&(O.delete(x),x.i(v))),function(t,e,i){const{fragment:n,after_update:o}=t.$$;n&&n.m(e,i),$(()=>{const e=t.$$.on_mount.map(s).filter(h);t.$$.on_destroy?t.$$.on_destroy.push(...e):r(e),t.$$.on_mount=[]}),o.forEach($)}(t,e.target,e.anchor),w()}var x,v,C;p(y)}class M{constructor(){e(this,"$$"),e(this,"$$set")}$destroy(){T(this,1),this.$destroy=n}$on(t,e){if(!h(e))return n;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");class U{constructor(t,e={}){this.container=t,this.options={threshold:e.threshold??.1,rootMargin:e.rootMargin??"0px",root:e.root??null,onVisible:e.onVisible,onHidden:e.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const e of t)e.target===this.container&&(e.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin,root:this.options.root||null}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function I(t){const e=t.charCodeAt(0);if(e<44032||e>55203)return[t];const i=e-44032,n=Math.floor(i/588),s=Math.floor(i%588/28),o=i%28,r=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],h=[];return h.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][n]),h.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][s]),o>0&&h.push(r[o]),h}function E(t,e,i){const n=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),s=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(e),o=i?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(i):0;if(-1===n||-1===s)return t+(e||"")+(i||"");const r=44032+21*n*28+28*s+o;return String.fromCharCode(r)}function R(t){const e=[],i=[];for(let n=0;n<t.length;n++){const s=t[n],o=s.charCodeAt(0),r=e.length;if(o>=44032&&o<=55203){const t=I(s);e.push(...t),i.push({start:r,end:e.length,isHangul:!0})}else e.push(s),i.push({start:r,end:e.length,isHangul:!1})}return{units:e,charUnitRanges:i}}class k{constructor(t,e){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=e.text,this.config={text:e.text,speed:e.speed??50,delay:e.delay??0,enabled:e.enabled??!0,threshold:e.threshold??.2,rootMargin:e.rootMargin??"0px 0px -100px 0px",triggerOnce:e.triggerOnce??!1,showCursor:e.showCursor??!0,cursorChar:e.cursorChar??"|",onUpdate:e.onUpdate||null,onComplete:e.onComplete||null};const i=R(this.config.text);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.injectStyles(),this.setupVisibilityManager()}injectStyles(){if(document.getElementById("masoneffect-typing-styles"))return;const t=document.createElement("style");t.id="masoneffect-typing-styles",t.textContent="\n .typing-char {\n transition: opacity 0.2s ease-in;\n display: inline-block;\n }\n .typing-cursor {\n display: inline-block;\n }\n ",document.head.appendChild(t)}setupVisibilityManager(){this.visibilityManager=new U(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,setTimeout(()=>this.start(),this.config.delay))},onHidden:()=>{}})}buildTextFromUnits(t){if(0===t)return"";let e="";for(let i=0;i<this.charUnitRanges.length;i++){const n=this.charUnitRanges[i];if(n.start>=t)break;const s=Math.min(t-n.start,n.end-n.start);if(s<=0)break;if(n.isHangul){const t=this.textUnits.slice(n.start,n.start+s);1===t.length?e+=t[0]:2===t.length?e+=E(t[0],t[1]):t.length>=3&&(e+=E(t[0],t[1],t[2]))}else s>0&&(e+=this.textUnits[n.start])}return e}start(){this.isRunning||(this.isRunning=!0,this.currentIndex=0,this.displayedText="",this.typeNext())}typeNext(){if(this.currentIndex>=this.textUnits.length)return this.isRunning=!1,this.config.showCursor&&this.updateDisplay(this.originalText),void(this.config.onComplete&&this.config.onComplete());this.displayedText=this.buildTextFromUnits(this.currentIndex+1);let t=this.displayedText;this.config.showCursor&&(t+=this.config.cursorChar),this.updateDisplay(t),this.config.onUpdate&&this.config.onUpdate(this.displayedText),this.currentIndex++,this.timeoutId=setTimeout(()=>{this.typeNext()},this.config.speed)}stop(){this.isRunning=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}reset(){this.stop(),this.currentIndex=0,this.displayedText="",this.hasTriggered=!1,this.updateDisplay("")}updateDisplay(t){const e=t.replace(new RegExp(this.escapeHtml(this.config.cursorChar)+"$"),""),i=t.endsWith(this.config.cursorChar),n=(this.container.textContent||"").replace(new RegExp(this.config.cursorChar+"$"),"");let s="";for(let r=0;r<e.length;r++){const t=e[r];s+=r>=n.length?`<span class="typing-char typing-fade-in" style="opacity: 0;">${this.escapeHtml(t)}</span>`:`<span class="typing-char" style="opacity: 1;">${this.escapeHtml(t)}</span>`}i&&(s+=`<span class="typing-cursor">${this.escapeHtml(this.config.cursorChar)}</span>`),this.container.innerHTML=s;const o=this.container.querySelectorAll(".typing-fade-in");o.length>0&&requestAnimationFrame(()=>{o.forEach(t=>{t.style.opacity="1",t.classList.remove("typing-fade-in")})})}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}setText(t){this.originalText=t,this.config.text=t;const e=R(t);this.textUnits=e.units,this.charUnitRanges=e.charUnitRanges,this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}function P(t){let e;return{c(){var i;i="div",e=document.createElement(i),u(e,"class",t[1]),u(e,"style",t[2])},m(i,n){!function(t,e,i){t.insertBefore(e,i||null)}(i,e,n),t[8](e)},p:n,i:n,o:n,d(i){i&&c(e),t[8](null)}}}function A(t,e,n){let s,o;a(t,effect,t=>n(10,s=t)),a(t,props,t=>n(11,o=t));let{text:r,speed:h=50,delay:l=0,enabled:c=!0,threshold:u=.2,rootMargin:d="0px 0px -100px 0px",triggerOnce:p=!1,showCursor:g=!0,cursorChar:y="|",className:b="",style:m="",onUpdate:x,onComplete:$}=o(),v=null,C=null;return i.onMount(()=>{if(!v)return;C=new k(v,{text:r,speed:h,delay:l,enabled:c,threshold:u,rootMargin:d,triggerOnce:p,showCursor:g,cursorChar:y,onUpdate:x,onComplete:$})}),i.onDestroy(()=>{C&&(C.destroy(),C=null)}),s(()=>{C&&r!==C.originalText&&C.setText(r)}),[v,b,m,function(){null==C||C.start()},function(){null==C||C.stop()},function(){null==C||C.reset()},function(t){null==C||C.setText(t)},function(){C&&(C.destroy(),C=null)},function(t){f[t?"unshift":"push"](()=>{v=t,n(0,v)})}]}module.exports=class extends M{constructor(t){super(),H(this,t,A,P,l,{start:3,stop:4,reset:5,setText:6,destroy:7})}get start(){return this.$$.ctx[3]}get stop(){return this.$$.ctx[4]}get reset(){return this.$$.ctx[5]}get setText(){return this.$$.ctx[6]}get destroy(){return this.$$.ctx[7]}};
@@ -36,15 +36,13 @@ export declare interface CountOptions {
36
36
  onComplete?: () => void;
37
37
  }
38
38
 
39
- declare const easingFunctions: {
39
+ export declare const easingFunctions: {
40
40
  linear: (t: number) => number;
41
41
  easeInQuad: (t: number) => number;
42
42
  easeOutQuad: (t: number) => number;
43
43
  easeInOutQuad: (t: number) => number;
44
44
  easeOutCubic: (t: number) => number;
45
45
  };
46
- export { easingFunctions }
47
- export { easingFunctions as scrollFadeInEasingFunctions }
48
46
 
49
47
  export declare interface Particle {
50
48
  x: number;
@@ -60,11 +58,12 @@ export declare interface Particle {
60
58
 
61
59
  export declare class ScrollFadeIn {
62
60
  container: HTMLElement;
63
- config: Required<Omit<ScrollFadeInOptions, 'onStart' | 'onComplete' | 'easing'>> & {
64
- easing: (t: number) => number;
61
+ config: Required<Omit<ScrollFadeInOptions, 'onStart' | 'onComplete' | 'root'>> & {
62
+ root: HTMLElement | null;
65
63
  onStart: ScrollFadeInOptions['onStart'];
66
64
  onComplete: ScrollFadeInOptions['onComplete'];
67
65
  };
66
+ private easing;
68
67
  visibilityManager: VisibilityManager | null;
69
68
  animationFrameId: number | null;
70
69
  startTime: number | null;
@@ -90,9 +89,9 @@ export declare interface ScrollFadeInOptions {
90
89
  direction?: 'top' | 'right' | 'bottom' | 'left';
91
90
  distance?: string;
92
91
  duration?: number;
93
- easing?: (t: number) => number;
94
92
  threshold?: number;
95
93
  rootMargin?: string;
94
+ root?: HTMLElement | null;
96
95
  triggerOnce?: boolean;
97
96
  enabled?: boolean;
98
97
  onStart?: () => void;
@@ -209,6 +208,7 @@ declare class TextToParticle {
209
208
  originalText: string;
210
209
  constructor(container: HTMLElement | string, options: TypingOptions);
211
210
  init(): void;
211
+ private injectStyles;
212
212
  setupVisibilityManager(): void;
213
213
  private buildTextFromUnits;
214
214
  start(): void;
@@ -216,6 +216,7 @@ declare class TextToParticle {
216
216
  stop(): void;
217
217
  reset(): void;
218
218
  updateDisplay(text: string): void;
219
+ private escapeHtml;
219
220
  setText(newText: string): void;
220
221
  destroy(): void;
221
222
  }
@@ -265,6 +266,7 @@ declare class TextToParticle {
265
266
  declare interface VisibilityManagerOptions {
266
267
  threshold?: number;
267
268
  rootMargin?: string;
269
+ root?: HTMLElement | null;
268
270
  onVisible?: () => void;
269
271
  onHidden?: () => void;
270
272
  }
@@ -282,6 +282,8 @@ class VisibilityManager {
282
282
  this.options = {
283
283
  threshold: options.threshold ?? 0.1,
284
284
  rootMargin: options.rootMargin ?? "0px",
285
+ root: options.root ?? null,
286
+ // 기본값은 null (viewport 기준)
285
287
  onVisible: options.onVisible,
286
288
  onHidden: options.onHidden
287
289
  };
@@ -319,7 +321,9 @@ class VisibilityManager {
319
321
  },
320
322
  {
321
323
  threshold: this.options.threshold,
322
- rootMargin: this.options.rootMargin
324
+ rootMargin: this.options.rootMargin,
325
+ root: this.options.root || null
326
+ // null이면 viewport 기준, HTMLElement면 해당 요소 기준
323
327
  }
324
328
  );
325
329
  this.intersectionObserver.observe(this.container);
@@ -470,8 +474,26 @@ class Typing {
470
474
  }
471
475
  init() {
472
476
  this.updateDisplay("");
477
+ this.injectStyles();
473
478
  this.setupVisibilityManager();
474
479
  }
480
+ injectStyles() {
481
+ if (document.getElementById("masoneffect-typing-styles")) {
482
+ return;
483
+ }
484
+ const style = document.createElement("style");
485
+ style.id = "masoneffect-typing-styles";
486
+ style.textContent = `
487
+ .typing-char {
488
+ transition: opacity 0.2s ease-in;
489
+ display: inline-block;
490
+ }
491
+ .typing-cursor {
492
+ display: inline-block;
493
+ }
494
+ `;
495
+ document.head.appendChild(style);
496
+ }
475
497
  setupVisibilityManager() {
476
498
  this.visibilityManager = new VisibilityManager(this.container, {
477
499
  threshold: this.config.threshold,
@@ -564,7 +586,39 @@ class Typing {
564
586
  this.updateDisplay("");
565
587
  }
566
588
  updateDisplay(text) {
567
- this.container.textContent = text;
589
+ const textWithoutCursor = text.replace(new RegExp(this.escapeHtml(this.config.cursorChar) + "$"), "");
590
+ const hasCursor = text.endsWith(this.config.cursorChar);
591
+ const previousTextContent = this.container.textContent || "";
592
+ const previousTextWithoutCursor = previousTextContent.replace(new RegExp(this.config.cursorChar + "$"), "");
593
+ let html = "";
594
+ for (let i = 0; i < textWithoutCursor.length; i++) {
595
+ const char = textWithoutCursor[i];
596
+ const isNewChar = i >= previousTextWithoutCursor.length;
597
+ if (isNewChar) {
598
+ html += `<span class="typing-char typing-fade-in" style="opacity: 0;">${this.escapeHtml(char)}</span>`;
599
+ } else {
600
+ html += `<span class="typing-char" style="opacity: 1;">${this.escapeHtml(char)}</span>`;
601
+ }
602
+ }
603
+ if (hasCursor) {
604
+ html += `<span class="typing-cursor">${this.escapeHtml(this.config.cursorChar)}</span>`;
605
+ }
606
+ this.container.innerHTML = html;
607
+ const newChars = this.container.querySelectorAll(".typing-fade-in");
608
+ if (newChars.length > 0) {
609
+ requestAnimationFrame(() => {
610
+ newChars.forEach((char) => {
611
+ char.style.opacity = "1";
612
+ char.classList.remove("typing-fade-in");
613
+ });
614
+ });
615
+ }
616
+ }
617
+ // HTML 이스케이프 유틸리티
618
+ escapeHtml(text) {
619
+ const div = document.createElement("div");
620
+ div.textContent = text;
621
+ return div.innerHTML;
568
622
  }
569
623
  // 텍스트 변경
570
624
  setText(newText) {
@@ -16,7 +16,6 @@ export { Typing, default as TypingDefault } from './typing/index.js';
16
16
  export type { TypingOptions } from './typing/index.js';
17
17
  export { ScrollFadeIn, default as ScrollFadeInDefault } from './scrollFadeIn/index.js';
18
18
  export type { ScrollFadeInOptions } from './scrollFadeIn/index.js';
19
- export { easingFunctions as scrollFadeInEasingFunctions } from './scrollFadeIn/index.js';
20
19
  export { TextToParticle as MasonEffect } from './textToParticle/index.js';
21
20
  export type { TextToParticleOptions as MasonEffectOptions } from './textToParticle/index.js';
22
21
  export { default } from './textToParticle/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,cAAc,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC7F,YAAY,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGjF,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAClE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACvF,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,eAAe,IAAI,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAGzF,OAAO,EAAE,cAAc,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC1E,YAAY,EAAE,qBAAqB,IAAI,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG7F,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,cAAc,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC7F,YAAY,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGjF,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAClE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACvF,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,OAAO,EAAE,cAAc,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC1E,YAAY,EAAE,qBAAqB,IAAI,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG7F,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC"}
@@ -10,29 +10,22 @@ export interface ScrollFadeInOptions {
10
10
  direction?: 'top' | 'right' | 'bottom' | 'left';
11
11
  distance?: string;
12
12
  duration?: number;
13
- easing?: (t: number) => number;
14
13
  threshold?: number;
15
14
  rootMargin?: string;
15
+ root?: HTMLElement | null;
16
16
  triggerOnce?: boolean;
17
17
  enabled?: boolean;
18
18
  onStart?: () => void;
19
19
  onComplete?: () => void;
20
20
  }
21
- export declare const easingFunctions: {
22
- linear: (t: number) => number;
23
- easeInQuad: (t: number) => number;
24
- easeOutQuad: (t: number) => number;
25
- easeInOutQuad: (t: number) => number;
26
- easeOutCubic: (t: number) => number;
27
- easeInOutCubic: (t: number) => number;
28
- };
29
21
  export declare class ScrollFadeIn {
30
22
  container: HTMLElement;
31
- config: Required<Omit<ScrollFadeInOptions, 'onStart' | 'onComplete' | 'easing'>> & {
32
- easing: (t: number) => number;
23
+ config: Required<Omit<ScrollFadeInOptions, 'onStart' | 'onComplete' | 'root'>> & {
24
+ root: HTMLElement | null;
33
25
  onStart: ScrollFadeInOptions['onStart'];
34
26
  onComplete: ScrollFadeInOptions['onComplete'];
35
27
  };
28
+ private easing;
36
29
  visibilityManager: VisibilityManager | null;
37
30
  animationFrameId: number | null;
38
31
  startTime: number | null;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/scrollFadeIn/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAGD,eAAO,MAAM,eAAe;gBACd,MAAM;oBACF,MAAM;qBACL,MAAM;uBACJ,MAAM;sBACP,MAAM;wBACJ,MAAM;CAC3B,CAAC;AAEF,qBAAa,YAAY;IACvB,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,mBAAmB,EAAE,SAAS,GAAG,YAAY,GAAG,QAAQ,CAAC,CAAC,GAAG;QACjF,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;QAC9B,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;QACxC,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;KAC/C,CAAC;IACF,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;gBAEX,SAAS,EAAE,WAAW,GAAG,MAAM,EAAE,OAAO,GAAE,mBAAwB;IAqC9E,IAAI,IAAI,IAAI;IAiBZ,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAoCvC,kBAAkB,IAAI,IAAI;IAqC1B,sBAAsB,IAAI,IAAI;IAoB9B,KAAK,IAAI,IAAI;IAeb,OAAO,IAAI,IAAI;IAmDf,QAAQ,IAAI,IAAI;IAqBhB,KAAK,IAAI,IAAI;IAMb,IAAI,IAAI,IAAI;IASZ,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,IAAI;IAoC3D,OAAO,IAAI,IAAI;CAWhB;AAGD,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/scrollFadeIn/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAKD,qBAAa,YAAY;IACvB,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,mBAAmB,EAAE,SAAS,GAAG,YAAY,GAAG,MAAM,CAAC,CAAC,GAAG;QAC/E,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;QACzB,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;QACxC,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;KAC/C,CAAC;IACF,OAAO,CAAC,MAAM,CAAwB;IACtC,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;gBAEX,SAAS,EAAE,WAAW,GAAG,MAAM,EAAE,OAAO,GAAE,mBAAwB;IAwC9E,IAAI,IAAI,IAAI;IAiBZ,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAoCvC,kBAAkB,IAAI,IAAI;IAqC1B,sBAAsB,IAAI,IAAI;IA8B9B,KAAK,IAAI,IAAI;IAeb,OAAO,IAAI,IAAI;IAmDf,QAAQ,IAAI,IAAI;IAqBhB,KAAK,IAAI,IAAI;IAMb,IAAI,IAAI,IAAI;IASZ,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,IAAI;IAmC3D,OAAO,IAAI,IAAI;CAWhB;AAGD,eAAe,YAAY,CAAC"}
@@ -40,6 +40,7 @@ export declare class Typing {
40
40
  originalText: string;
41
41
  constructor(container: HTMLElement | string, options: TypingOptions);
42
42
  init(): void;
43
+ private injectStyles;
43
44
  setupVisibilityManager(): void;
44
45
  private buildTextFromUnits;
45
46
  start(): void;
@@ -47,6 +48,7 @@ export declare class Typing {
47
48
  stop(): void;
48
49
  reset(): void;
49
50
  updateDisplay(text: string): void;
51
+ private escapeHtml;
50
52
  setText(newText: string): void;
51
53
  destroy(): void;
52
54
  }