masoneffect 2.0.18 → 2.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/README.md +49 -358
  2. package/dist/core/count/index.d.ts.map +1 -1
  3. package/dist/core/count/index.test.d.ts +2 -0
  4. package/dist/core/count/index.test.d.ts.map +1 -0
  5. package/dist/core/scrollFadeIn/index.d.ts.map +1 -1
  6. package/dist/core/textSpin/index.d.ts.map +1 -1
  7. package/dist/core/textToParticle/index.d.ts.map +1 -1
  8. package/dist/core/typing/index.d.ts.map +1 -1
  9. package/dist/count/core/count/index.d.ts.map +1 -1
  10. package/dist/count/core/count/index.test.d.ts +2 -0
  11. package/dist/count/core/count/index.test.d.ts.map +1 -0
  12. package/dist/count/core/scrollFadeIn/index.d.ts.map +1 -1
  13. package/dist/count/core/textSpin/index.d.ts.map +1 -1
  14. package/dist/count/core/textToParticle/index.d.ts.map +1 -1
  15. package/dist/count/core/typing/index.d.ts.map +1 -1
  16. package/dist/count/react/MasonEffect.d.ts.map +1 -1
  17. package/dist/count/react/count/Count.d.ts.map +1 -1
  18. package/dist/count/react/index.d.ts +1 -1
  19. package/dist/count/react/index.d.ts.map +1 -1
  20. package/dist/count/react/scrollFadeIn/ScrollFadeIn.d.ts.map +1 -1
  21. package/dist/count/react/textSpin/TextSpin.d.ts.map +1 -1
  22. package/dist/count/react/textToParticle/TextToParticle.d.ts.map +1 -1
  23. package/dist/count/react/typing/Typing.d.ts.map +1 -1
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.mjs +1 -1
  26. package/dist/react/MasonEffect.d.ts.map +1 -1
  27. package/dist/react/core/count/index.test.d.ts +1 -0
  28. package/dist/react/count/Count.d.ts.map +1 -1
  29. package/dist/react/count/core/count/index.d.ts.map +1 -1
  30. package/dist/react/count/core/count/index.test.d.ts +2 -0
  31. package/dist/react/count/core/count/index.test.d.ts.map +1 -0
  32. package/dist/react/count/core/scrollFadeIn/index.d.ts.map +1 -1
  33. package/dist/react/count/core/textSpin/index.d.ts.map +1 -1
  34. package/dist/react/count/core/textToParticle/index.d.ts.map +1 -1
  35. package/dist/react/count/core/typing/index.d.ts.map +1 -1
  36. package/dist/react/count/index.cjs +1 -1
  37. package/dist/react/count/index.mjs +1 -1
  38. package/dist/react/count/react/MasonEffect.d.ts.map +1 -1
  39. package/dist/react/count/react/count/Count.d.ts.map +1 -1
  40. package/dist/react/count/react/index.d.ts +1 -1
  41. package/dist/react/count/react/index.d.ts.map +1 -1
  42. package/dist/react/count/react/scrollFadeIn/ScrollFadeIn.d.ts.map +1 -1
  43. package/dist/react/count/react/textSpin/TextSpin.d.ts.map +1 -1
  44. package/dist/react/count/react/textToParticle/TextToParticle.d.ts.map +1 -1
  45. package/dist/react/count/react/typing/Typing.d.ts.map +1 -1
  46. package/dist/react/index.d.ts.map +1 -1
  47. package/dist/react/react/index.d.ts +1 -1
  48. package/dist/react/scrollFadeIn/ScrollFadeIn.d.ts.map +1 -1
  49. package/dist/react/scrollFadeIn/core/count/index.d.ts.map +1 -1
  50. package/dist/react/scrollFadeIn/core/count/index.test.d.ts +2 -0
  51. package/dist/react/scrollFadeIn/core/count/index.test.d.ts.map +1 -0
  52. package/dist/react/scrollFadeIn/core/scrollFadeIn/index.d.ts.map +1 -1
  53. package/dist/react/scrollFadeIn/core/textSpin/index.d.ts.map +1 -1
  54. package/dist/react/scrollFadeIn/core/textToParticle/index.d.ts.map +1 -1
  55. package/dist/react/scrollFadeIn/core/typing/index.d.ts.map +1 -1
  56. package/dist/react/scrollFadeIn/index.cjs +1 -1
  57. package/dist/react/scrollFadeIn/index.mjs +1 -1
  58. package/dist/react/scrollFadeIn/react/MasonEffect.d.ts.map +1 -1
  59. package/dist/react/scrollFadeIn/react/count/Count.d.ts.map +1 -1
  60. package/dist/react/scrollFadeIn/react/index.d.ts +1 -1
  61. package/dist/react/scrollFadeIn/react/index.d.ts.map +1 -1
  62. package/dist/react/scrollFadeIn/react/scrollFadeIn/ScrollFadeIn.d.ts.map +1 -1
  63. package/dist/react/scrollFadeIn/react/textSpin/TextSpin.d.ts.map +1 -1
  64. package/dist/react/scrollFadeIn/react/textToParticle/TextToParticle.d.ts.map +1 -1
  65. package/dist/react/scrollFadeIn/react/typing/Typing.d.ts.map +1 -1
  66. package/dist/react/textSpin/TextSpin.d.ts.map +1 -1
  67. package/dist/react/textSpin/core/count/index.d.ts.map +1 -1
  68. package/dist/react/textSpin/core/count/index.test.d.ts +2 -0
  69. package/dist/react/textSpin/core/count/index.test.d.ts.map +1 -0
  70. package/dist/react/textSpin/core/scrollFadeIn/index.d.ts.map +1 -1
  71. package/dist/react/textSpin/core/textSpin/index.d.ts.map +1 -1
  72. package/dist/react/textSpin/core/textToParticle/index.d.ts.map +1 -1
  73. package/dist/react/textSpin/core/typing/index.d.ts.map +1 -1
  74. package/dist/react/textSpin/index.cjs +1 -1
  75. package/dist/react/textSpin/index.mjs +1 -1
  76. package/dist/react/textSpin/react/MasonEffect.d.ts.map +1 -1
  77. package/dist/react/textSpin/react/count/Count.d.ts.map +1 -1
  78. package/dist/react/textSpin/react/index.d.ts +1 -1
  79. package/dist/react/textSpin/react/index.d.ts.map +1 -1
  80. package/dist/react/textSpin/react/scrollFadeIn/ScrollFadeIn.d.ts.map +1 -1
  81. package/dist/react/textSpin/react/textSpin/TextSpin.d.ts.map +1 -1
  82. package/dist/react/textSpin/react/textToParticle/TextToParticle.d.ts.map +1 -1
  83. package/dist/react/textSpin/react/typing/Typing.d.ts.map +1 -1
  84. package/dist/react/textToParticle/TextToParticle.d.ts.map +1 -1
  85. package/dist/react/textToParticle/core/count/index.d.ts.map +1 -1
  86. package/dist/react/textToParticle/core/count/index.test.d.ts +2 -0
  87. package/dist/react/textToParticle/core/count/index.test.d.ts.map +1 -0
  88. package/dist/react/textToParticle/core/scrollFadeIn/index.d.ts.map +1 -1
  89. package/dist/react/textToParticle/core/textSpin/index.d.ts.map +1 -1
  90. package/dist/react/textToParticle/core/textToParticle/index.d.ts.map +1 -1
  91. package/dist/react/textToParticle/core/typing/index.d.ts.map +1 -1
  92. package/dist/react/textToParticle/index.cjs +1 -1
  93. package/dist/react/textToParticle/index.mjs +1 -1
  94. package/dist/react/textToParticle/react/MasonEffect.d.ts.map +1 -1
  95. package/dist/react/textToParticle/react/count/Count.d.ts.map +1 -1
  96. package/dist/react/textToParticle/react/index.d.ts +1 -1
  97. package/dist/react/textToParticle/react/index.d.ts.map +1 -1
  98. package/dist/react/textToParticle/react/scrollFadeIn/ScrollFadeIn.d.ts.map +1 -1
  99. package/dist/react/textToParticle/react/textSpin/TextSpin.d.ts.map +1 -1
  100. package/dist/react/textToParticle/react/textToParticle/TextToParticle.d.ts.map +1 -1
  101. package/dist/react/textToParticle/react/typing/Typing.d.ts.map +1 -1
  102. package/dist/react/typing/Typing.d.ts.map +1 -1
  103. package/dist/react/typing/core/count/index.d.ts.map +1 -1
  104. package/dist/react/typing/core/count/index.test.d.ts +2 -0
  105. package/dist/react/typing/core/count/index.test.d.ts.map +1 -0
  106. package/dist/react/typing/core/scrollFadeIn/index.d.ts.map +1 -1
  107. package/dist/react/typing/core/textSpin/index.d.ts.map +1 -1
  108. package/dist/react/typing/core/textToParticle/index.d.ts.map +1 -1
  109. package/dist/react/typing/core/typing/index.d.ts.map +1 -1
  110. package/dist/react/typing/index.cjs +1 -1
  111. package/dist/react/typing/index.mjs +1 -1
  112. package/dist/react/typing/react/MasonEffect.d.ts.map +1 -1
  113. package/dist/react/typing/react/count/Count.d.ts.map +1 -1
  114. package/dist/react/typing/react/index.d.ts +1 -1
  115. package/dist/react/typing/react/index.d.ts.map +1 -1
  116. package/dist/react/typing/react/scrollFadeIn/ScrollFadeIn.d.ts.map +1 -1
  117. package/dist/react/typing/react/textSpin/TextSpin.d.ts.map +1 -1
  118. package/dist/react/typing/react/textToParticle/TextToParticle.d.ts.map +1 -1
  119. package/dist/react/typing/react/typing/Typing.d.ts.map +1 -1
  120. package/dist/scrollFadeIn/core/count/index.d.ts.map +1 -1
  121. package/dist/scrollFadeIn/core/count/index.test.d.ts +2 -0
  122. package/dist/scrollFadeIn/core/count/index.test.d.ts.map +1 -0
  123. package/dist/scrollFadeIn/core/scrollFadeIn/index.d.ts.map +1 -1
  124. package/dist/scrollFadeIn/core/textSpin/index.d.ts.map +1 -1
  125. package/dist/scrollFadeIn/core/textToParticle/index.d.ts.map +1 -1
  126. package/dist/scrollFadeIn/core/typing/index.d.ts.map +1 -1
  127. package/dist/scrollFadeIn/index.cjs +1 -1
  128. package/dist/scrollFadeIn/index.mjs +1 -1
  129. package/dist/scrollFadeIn/react/MasonEffect.d.ts.map +1 -1
  130. package/dist/scrollFadeIn/react/count/Count.d.ts.map +1 -1
  131. package/dist/scrollFadeIn/react/index.d.ts +1 -1
  132. package/dist/scrollFadeIn/react/index.d.ts.map +1 -1
  133. package/dist/scrollFadeIn/react/scrollFadeIn/ScrollFadeIn.d.ts.map +1 -1
  134. package/dist/scrollFadeIn/react/textSpin/TextSpin.d.ts.map +1 -1
  135. package/dist/scrollFadeIn/react/textToParticle/TextToParticle.d.ts.map +1 -1
  136. package/dist/scrollFadeIn/react/typing/Typing.d.ts.map +1 -1
  137. package/dist/svelte/index.cjs +1 -1
  138. package/dist/svelte/index.mjs +165 -13
  139. package/dist/svelte/scrollFadeIn/index.cjs +1 -1
  140. package/dist/svelte/scrollFadeIn/index.mjs +4 -2
  141. package/dist/svelte/textSpin/index.cjs +1 -1
  142. package/dist/svelte/textSpin/index.mjs +1 -2
  143. package/dist/svelte/textToParticle/index.mjs +4 -1
  144. package/dist/svelte/typing/index.mjs +156 -8
  145. package/dist/textSpin/core/count/index.d.ts.map +1 -1
  146. package/dist/textSpin/core/count/index.test.d.ts +2 -0
  147. package/dist/textSpin/core/count/index.test.d.ts.map +1 -0
  148. package/dist/textSpin/core/scrollFadeIn/index.d.ts.map +1 -1
  149. package/dist/textSpin/core/textSpin/index.d.ts.map +1 -1
  150. package/dist/textSpin/core/textToParticle/index.d.ts.map +1 -1
  151. package/dist/textSpin/core/typing/index.d.ts.map +1 -1
  152. package/dist/textSpin/index.cjs +1 -1
  153. package/dist/textSpin/index.mjs +1 -1
  154. package/dist/textSpin/react/MasonEffect.d.ts.map +1 -1
  155. package/dist/textSpin/react/count/Count.d.ts.map +1 -1
  156. package/dist/textSpin/react/index.d.ts +1 -1
  157. package/dist/textSpin/react/index.d.ts.map +1 -1
  158. package/dist/textSpin/react/scrollFadeIn/ScrollFadeIn.d.ts.map +1 -1
  159. package/dist/textSpin/react/textSpin/TextSpin.d.ts.map +1 -1
  160. package/dist/textSpin/react/textToParticle/TextToParticle.d.ts.map +1 -1
  161. package/dist/textSpin/react/typing/Typing.d.ts.map +1 -1
  162. package/dist/textToParticle/core/count/index.d.ts.map +1 -1
  163. package/dist/textToParticle/core/count/index.test.d.ts +2 -0
  164. package/dist/textToParticle/core/count/index.test.d.ts.map +1 -0
  165. package/dist/textToParticle/core/scrollFadeIn/index.d.ts.map +1 -1
  166. package/dist/textToParticle/core/textSpin/index.d.ts.map +1 -1
  167. package/dist/textToParticle/core/textToParticle/index.d.ts.map +1 -1
  168. package/dist/textToParticle/core/typing/index.d.ts.map +1 -1
  169. package/dist/textToParticle/react/MasonEffect.d.ts.map +1 -1
  170. package/dist/textToParticle/react/count/Count.d.ts.map +1 -1
  171. package/dist/textToParticle/react/index.d.ts +1 -1
  172. package/dist/textToParticle/react/index.d.ts.map +1 -1
  173. package/dist/textToParticle/react/scrollFadeIn/ScrollFadeIn.d.ts.map +1 -1
  174. package/dist/textToParticle/react/textSpin/TextSpin.d.ts.map +1 -1
  175. package/dist/textToParticle/react/textToParticle/TextToParticle.d.ts.map +1 -1
  176. package/dist/textToParticle/react/typing/Typing.d.ts.map +1 -1
  177. package/dist/typing/core/count/index.d.ts.map +1 -1
  178. package/dist/typing/core/count/index.test.d.ts +2 -0
  179. package/dist/typing/core/count/index.test.d.ts.map +1 -0
  180. package/dist/typing/core/scrollFadeIn/index.d.ts.map +1 -1
  181. package/dist/typing/core/textSpin/index.d.ts.map +1 -1
  182. package/dist/typing/core/textToParticle/index.d.ts.map +1 -1
  183. package/dist/typing/core/typing/index.d.ts.map +1 -1
  184. package/dist/typing/react/MasonEffect.d.ts.map +1 -1
  185. package/dist/typing/react/count/Count.d.ts.map +1 -1
  186. package/dist/typing/react/index.d.ts +1 -1
  187. package/dist/typing/react/index.d.ts.map +1 -1
  188. package/dist/typing/react/scrollFadeIn/ScrollFadeIn.d.ts.map +1 -1
  189. package/dist/typing/react/textSpin/TextSpin.d.ts.map +1 -1
  190. package/dist/typing/react/textToParticle/TextToParticle.d.ts.map +1 -1
  191. package/dist/typing/react/typing/Typing.d.ts.map +1 -1
  192. package/dist/vue/index.cjs +1 -1
  193. package/dist/vue/index.mjs +244 -20
  194. package/dist/vue/scrollFadeIn/index.cjs +1 -1
  195. package/dist/vue/scrollFadeIn/index.mjs +4 -2
  196. package/dist/vue/textSpin/index.cjs +1 -1
  197. package/dist/vue/textSpin/index.mjs +1 -2
  198. package/dist/vue/textToParticle/index.cjs +1 -1
  199. package/dist/vue/textToParticle/index.mjs +79 -4
  200. package/dist/vue/typing/index.cjs +1 -1
  201. package/dist/vue/typing/index.mjs +160 -12
  202. package/package.json +35 -14
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, watch, onMounted, onBeforeUnmount, createElementBlock, openBlock, normalizeStyle, normalizeClass, onUnmounted, renderSlot } from "vue";
1
+ import { defineComponent, ref, computed, watch, onMounted, onBeforeUnmount, createElementBlock, openBlock, normalizeStyle, normalizeClass, onUnmounted, renderSlot } from "vue";
2
2
  class VisibilityManager {
3
3
  constructor(container, options = {}) {
4
4
  this.container = container;
@@ -170,7 +170,10 @@ class TextToParticle {
170
170
  this.handleMouseDown = this.handleMouseDown.bind(this);
171
171
  this.handleMouseUp = this.handleMouseUp.bind(this);
172
172
  this._debouncedMorph = debounce(this._morphInternal.bind(this), this.debounceDelay);
173
- this._debouncedUpdateConfig = debounce(this._updateConfigInternal.bind(this), this.debounceDelay);
173
+ this._debouncedUpdateConfig = debounce(
174
+ this._updateConfigInternal.bind(this),
175
+ this.debounceDelay
176
+ );
174
177
  this.init();
175
178
  }
176
179
  init() {
@@ -660,9 +663,80 @@ function decomposeHangul(char) {
660
663
  const initial = Math.floor(base / (21 * 28));
661
664
  const medial = Math.floor(base % (21 * 28) / 28);
662
665
  const final = base % 28;
663
- const initialChars = ["ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅉ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"];
664
- const medialChars = ["", "ㅐ", "ㅑ", "ㅒ", "ㅓ", "ㅔ", "ㅕ", "ㅖ", "ㅗ", "ㅘ", "ㅙ", "ㅚ", "ㅛ", "ㅜ", "ㅝ", "ㅞ", "ㅟ", "ㅠ", "ㅡ", "ㅢ", "ㅣ"];
665
- const finalChars = ["", "ㄱ", "ㄲ", "ㄳ", "ㄴ", "ㄵ", "ㄶ", "ㄷ", "ㄹ", "ㄺ", "ㄻ", "ㄼ", "ㄽ", "ㄾ", "ㄿ", "ㅀ", "ㅁ", "ㅂ", "ㅄ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"];
666
+ const initialChars = [
667
+ "",
668
+ "ㄲ",
669
+ "ㄴ",
670
+ "ㄷ",
671
+ "ㄸ",
672
+ "ㄹ",
673
+ "ㅁ",
674
+ "ㅂ",
675
+ "ㅃ",
676
+ "ㅅ",
677
+ "ㅆ",
678
+ "ㅇ",
679
+ "ㅈ",
680
+ "ㅉ",
681
+ "ㅊ",
682
+ "ㅋ",
683
+ "ㅌ",
684
+ "ㅍ",
685
+ "ㅎ"
686
+ ];
687
+ const medialChars = [
688
+ "ㅏ",
689
+ "ㅐ",
690
+ "ㅑ",
691
+ "ㅒ",
692
+ "ㅓ",
693
+ "ㅔ",
694
+ "ㅕ",
695
+ "ㅖ",
696
+ "ㅗ",
697
+ "ㅘ",
698
+ "ㅙ",
699
+ "ㅚ",
700
+ "ㅛ",
701
+ "ㅜ",
702
+ "ㅝ",
703
+ "ㅞ",
704
+ "ㅟ",
705
+ "ㅠ",
706
+ "ㅡ",
707
+ "ㅢ",
708
+ "ㅣ"
709
+ ];
710
+ const finalChars = [
711
+ "",
712
+ "ㄱ",
713
+ "ㄲ",
714
+ "ㄳ",
715
+ "ㄴ",
716
+ "ㄵ",
717
+ "ㄶ",
718
+ "ㄷ",
719
+ "ㄹ",
720
+ "ㄺ",
721
+ "ㄻ",
722
+ "ㄼ",
723
+ "ㄽ",
724
+ "ㄾ",
725
+ "ㄿ",
726
+ "ㅀ",
727
+ "ㅁ",
728
+ "ㅂ",
729
+ "ㅄ",
730
+ "ㅅ",
731
+ "ㅆ",
732
+ "ㅇ",
733
+ "ㅈ",
734
+ "ㅊ",
735
+ "ㅋ",
736
+ "ㅌ",
737
+ "ㅍ",
738
+ "ㅎ"
739
+ ];
666
740
  const result = [];
667
741
  result.push(initialChars[initial]);
668
742
  result.push(medialChars[medial]);
@@ -672,9 +746,80 @@ function decomposeHangul(char) {
672
746
  return result;
673
747
  }
674
748
  function composeHangul(initial, medial, final) {
675
- const initialChars = ["ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅉ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"];
676
- const medialChars = ["", "ㅐ", "ㅑ", "ㅒ", "ㅓ", "ㅔ", "ㅕ", "ㅖ", "ㅗ", "ㅘ", "ㅙ", "ㅚ", "ㅛ", "ㅜ", "ㅝ", "ㅞ", "ㅟ", "ㅠ", "ㅡ", "ㅢ", "ㅣ"];
677
- const finalChars = ["", "ㄱ", "ㄲ", "ㄳ", "ㄴ", "ㄵ", "ㄶ", "ㄷ", "ㄹ", "ㄺ", "ㄻ", "ㄼ", "ㄽ", "ㄾ", "ㄿ", "ㅀ", "ㅁ", "ㅂ", "ㅄ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"];
749
+ const initialChars = [
750
+ "",
751
+ "ㄲ",
752
+ "ㄴ",
753
+ "ㄷ",
754
+ "ㄸ",
755
+ "ㄹ",
756
+ "ㅁ",
757
+ "ㅂ",
758
+ "ㅃ",
759
+ "ㅅ",
760
+ "ㅆ",
761
+ "ㅇ",
762
+ "ㅈ",
763
+ "ㅉ",
764
+ "ㅊ",
765
+ "ㅋ",
766
+ "ㅌ",
767
+ "ㅍ",
768
+ "ㅎ"
769
+ ];
770
+ const medialChars = [
771
+ "ㅏ",
772
+ "ㅐ",
773
+ "ㅑ",
774
+ "ㅒ",
775
+ "ㅓ",
776
+ "ㅔ",
777
+ "ㅕ",
778
+ "ㅖ",
779
+ "ㅗ",
780
+ "ㅘ",
781
+ "ㅙ",
782
+ "ㅚ",
783
+ "ㅛ",
784
+ "ㅜ",
785
+ "ㅝ",
786
+ "ㅞ",
787
+ "ㅟ",
788
+ "ㅠ",
789
+ "ㅡ",
790
+ "ㅢ",
791
+ "ㅣ"
792
+ ];
793
+ const finalChars = [
794
+ "",
795
+ "ㄱ",
796
+ "ㄲ",
797
+ "ㄳ",
798
+ "ㄴ",
799
+ "ㄵ",
800
+ "ㄶ",
801
+ "ㄷ",
802
+ "ㄹ",
803
+ "ㄺ",
804
+ "ㄻ",
805
+ "ㄼ",
806
+ "ㄽ",
807
+ "ㄾ",
808
+ "ㄿ",
809
+ "ㅀ",
810
+ "ㅁ",
811
+ "ㅂ",
812
+ "ㅄ",
813
+ "ㅅ",
814
+ "ㅆ",
815
+ "ㅇ",
816
+ "ㅈ",
817
+ "ㅊ",
818
+ "ㅋ",
819
+ "ㅌ",
820
+ "ㅍ",
821
+ "ㅎ"
822
+ ];
678
823
  const initialIndex = initialChars.indexOf(initial);
679
824
  const medialIndex = medialChars.indexOf(medial);
680
825
  const finalIndex = final ? finalChars.indexOf(final) : 0;
@@ -857,10 +1002,16 @@ class Typing {
857
1002
  this.updateDisplay("");
858
1003
  }
859
1004
  updateDisplay(text) {
860
- const textWithoutCursor = text.replace(new RegExp(this.escapeHtml(this.config.cursorChar) + "$"), "");
1005
+ const textWithoutCursor = text.replace(
1006
+ new RegExp(this.escapeHtml(this.config.cursorChar) + "$"),
1007
+ ""
1008
+ );
861
1009
  const hasCursor = text.endsWith(this.config.cursorChar);
862
1010
  const previousTextContent = this.container.textContent || "";
863
- const previousTextWithoutCursor = previousTextContent.replace(new RegExp(this.config.cursorChar + "$"), "");
1011
+ const previousTextWithoutCursor = previousTextContent.replace(
1012
+ new RegExp(this.config.cursorChar + "$"),
1013
+ ""
1014
+ );
864
1015
  let html = "";
865
1016
  for (let i = 0; i < textWithoutCursor.length; i++) {
866
1017
  const char = textWithoutCursor[i];
@@ -962,13 +1113,15 @@ class ScrollFadeIn {
962
1113
  case "px":
963
1114
  return value;
964
1115
  case "rem":
965
- case "em":
1116
+ case "em": {
966
1117
  const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
967
1118
  return value * fontSize;
968
- case "%":
1119
+ }
1120
+ case "%": {
969
1121
  const rect = this.container.getBoundingClientRect();
970
1122
  const dimension = this.config.direction === "top" || this.config.direction === "bottom" ? rect.height : rect.width;
971
1123
  return value / 100 * dimension;
1124
+ }
972
1125
  case "vh":
973
1126
  return value / 100 * window.innerHeight;
974
1127
  case "vw":
@@ -1209,7 +1362,7 @@ class TextSpin {
1209
1362
  chars.forEach(() => {
1210
1363
  this.randomPoints.push(Math.random());
1211
1364
  });
1212
- chars.forEach((char, index) => {
1365
+ chars.forEach((char) => {
1213
1366
  const charElement = document.createElement("span");
1214
1367
  charElement.className = "masoneffect-textspin-char";
1215
1368
  charElement.style.transition = `opacity ${this.config.duration}s ease-out, transform ${this.config.duration}s ease-out`;
@@ -1297,7 +1450,6 @@ class TextSpin {
1297
1450
  updateConfig(newConfig) {
1298
1451
  var _a;
1299
1452
  const wasActive = this.isActive;
1300
- this.config.enabled;
1301
1453
  const isEnabledChanging = newConfig.enabled !== void 0 && newConfig.enabled !== this.config.enabled;
1302
1454
  if (isEnabledChanging && newConfig.enabled === false) {
1303
1455
  this.stop();
@@ -1370,8 +1522,60 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1370
1522
  const emit = __emit;
1371
1523
  const container = ref(null);
1372
1524
  let instance = null;
1525
+ let resizeObserver = null;
1526
+ let tempResizeObserver = null;
1527
+ let initTimeout = null;
1528
+ const defaultStyle = computed(() => ({
1529
+ width: "100%",
1530
+ height: "100%",
1531
+ minHeight: 300,
1532
+ position: "relative",
1533
+ ...props.style
1534
+ }));
1373
1535
  const init = () => {
1374
1536
  if (!container.value) return;
1537
+ if (instance) {
1538
+ return;
1539
+ }
1540
+ const existingCanvas = container.value.querySelector("canvas");
1541
+ if (existingCanvas) {
1542
+ existingCanvas.remove();
1543
+ }
1544
+ const rect = container.value.getBoundingClientRect();
1545
+ const hasValidSize = rect.width > 0 && rect.height > 0;
1546
+ if (!hasValidSize) {
1547
+ if (typeof ResizeObserver !== "undefined") {
1548
+ let resizeCheckCount = 0;
1549
+ const maxResizeChecks = 20;
1550
+ if (tempResizeObserver) {
1551
+ tempResizeObserver.disconnect();
1552
+ tempResizeObserver = null;
1553
+ }
1554
+ tempResizeObserver = new ResizeObserver(() => {
1555
+ var _a;
1556
+ resizeCheckCount++;
1557
+ const newRect = (_a = container.value) == null ? void 0 : _a.getBoundingClientRect();
1558
+ if (newRect && newRect.width > 0 && newRect.height > 0) {
1559
+ if (tempResizeObserver) {
1560
+ tempResizeObserver.disconnect();
1561
+ tempResizeObserver = null;
1562
+ }
1563
+ init();
1564
+ } else if (resizeCheckCount >= maxResizeChecks) {
1565
+ if (tempResizeObserver) {
1566
+ tempResizeObserver.disconnect();
1567
+ tempResizeObserver = null;
1568
+ }
1569
+ init();
1570
+ }
1571
+ });
1572
+ tempResizeObserver.observe(container.value);
1573
+ return;
1574
+ } else {
1575
+ initTimeout = window.setTimeout(init, 50);
1576
+ return;
1577
+ }
1578
+ }
1375
1579
  const options = {
1376
1580
  text: props.text,
1377
1581
  densityStep: props.densityStep,
@@ -1396,6 +1600,14 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1396
1600
  }
1397
1601
  };
1398
1602
  instance = new TextToParticle(container.value, options);
1603
+ if (typeof ResizeObserver !== "undefined") {
1604
+ resizeObserver = new ResizeObserver(() => {
1605
+ if (instance) {
1606
+ instance.resize();
1607
+ }
1608
+ });
1609
+ resizeObserver.observe(container.value);
1610
+ }
1399
1611
  };
1400
1612
  watch(
1401
1613
  () => [
@@ -1434,9 +1646,21 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1434
1646
  }
1435
1647
  );
1436
1648
  onMounted(() => {
1437
- init();
1649
+ requestAnimationFrame(init);
1438
1650
  });
1439
1651
  onBeforeUnmount(() => {
1652
+ if (initTimeout) {
1653
+ clearTimeout(initTimeout);
1654
+ initTimeout = null;
1655
+ }
1656
+ if (tempResizeObserver) {
1657
+ tempResizeObserver.disconnect();
1658
+ tempResizeObserver = null;
1659
+ }
1660
+ if (resizeObserver) {
1661
+ resizeObserver.disconnect();
1662
+ resizeObserver = null;
1663
+ }
1440
1664
  if (instance) {
1441
1665
  instance.destroy();
1442
1666
  instance = null;
@@ -1464,7 +1688,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1464
1688
  ref_key: "container",
1465
1689
  ref: container,
1466
1690
  class: normalizeClass(__props.className),
1467
- style: normalizeStyle(__props.style)
1691
+ style: normalizeStyle(defaultStyle.value)
1468
1692
  }, null, 6);
1469
1693
  };
1470
1694
  }
@@ -1593,10 +1817,10 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1593
1817
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1594
1818
  __name: "Typing",
1595
1819
  props: {
1596
- className: {},
1597
- style: {},
1598
- onUpdate: {},
1599
- onComplete: {},
1820
+ className: { default: void 0 },
1821
+ style: { default: void 0 },
1822
+ onUpdate: { type: Function, default: void 0 },
1823
+ onComplete: { type: Function, default: void 0 },
1600
1824
  text: {},
1601
1825
  speed: { default: 50 },
1602
1826
  delay: { default: 0 },
@@ -1 +1 @@
1
- "use strict";const t=require("vue");class i{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)}}const e=t=>--t*t*t+1;class n{constructor(t,i={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={direction:i.direction??"bottom",distance:i.distance??"50px",duration:i.duration??800,threshold:i.threshold??.1,rootMargin:i.rootMargin??"0px",root:i.root??null,triggerOnce:i.triggerOnce??!1,enabled:i.enabled??!0,onStart:i.onStart||null,onComplete:i.onComplete||null},this.easing=e,this.visibilityManager=null,this.animationFrameId=null,this.startTime=null,this.isRunning=!1,this.hasTriggered=!1,this.initialTransform="",this.targetDistance=0,this.init()}init(){const t=window.getComputedStyle(this.container);this.initialTransform="none"!==t.transform?t.transform:this.container.style.transform||"",this.targetDistance=this.parseDistance(this.config.distance),this.setInitialPosition(),this.setupVisibilityManager()}parseDistance(t){const i=t.match(/^(-?\d+\.?\d*)(px|rem|em|%|vh|vw)$/);if(!i){return parseFloat(t)||50}const e=parseFloat(i[1]);switch(i[2]){case"px":default:return e;case"rem":case"em":return e*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16);case"%":const t=this.container.getBoundingClientRect();return e/100*("top"===this.config.direction||"bottom"===this.config.direction?t.height:t.width);case"vh":return e/100*window.innerHeight;case"vw":return e/100*window.innerWidth}}setInitialPosition(){let t=0,i=0;switch(this.config.direction){case"top":i=-this.targetDistance;break;case"right":t=this.targetDistance;break;case"bottom":i=this.targetDistance;break;case"left":t=-this.targetDistance}const e=this.initialTransform||"",n=`translate(${t}px, ${i}px)`;this.container.style.transform=e&&"none"!==e?`${n} ${e}`:n,this.container.style.opacity="0",this.container.style.transition="none"}setupVisibilityManager(){this.visibilityManager=new i(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,root:this.config.root,onVisible:()=>{this.config.enabled&&(this.config.triggerOnce&&this.hasTriggered||(this.hasTriggered=!0,this.start()))},onHidden:()=>{this.config.enabled&&(this.stop(),this.config.triggerOnce||(this.hasTriggered=!1),this.setInitialPosition())}})}start(){this.isRunning||(this.isRunning=!0,this.startTime=performance.now(),this.config.onStart&&this.config.onStart(),this.container.style.transition="none",this.animate())}animate(){if(!this.isRunning)return;const t=performance.now()-(this.startTime||0),i=Math.min(t/this.config.duration,1),e=this.easing(i);let n=0,s=0;switch(this.config.direction){case"top":s=-this.targetDistance*(1-e);break;case"right":n=this.targetDistance*(1-e);break;case"bottom":s=this.targetDistance*(1-e);break;case"left":n=-this.targetDistance*(1-e)}const o=this.initialTransform||"",r=`translate(${n}px, ${s}px)`;this.container.style.transform=o&&"none"!==o?`${r} ${o}`:r,this.container.style.opacity=String(e),i<1?this.animationFrameId=requestAnimationFrame(()=>this.animate()):this.complete()}complete(){this.isRunning=!1,this.initialTransform&&"none"!==this.initialTransform?this.container.style.transform=this.initialTransform:this.container.style.transform="",this.container.style.opacity="1",this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.config.onComplete&&this.config.onComplete()}reset(){this.stop(),this.hasTriggered=!1,this.setInitialPosition()}stop(){this.isRunning=!1,this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}updateConfig(t){const i=this.isRunning;this.stop(),this.config={...this.config,...t,onStart:t.onStart??this.config.onStart,onComplete:t.onComplete??this.config.onComplete},t.distance&&(this.targetDistance=this.parseDistance(this.config.distance)),this.setInitialPosition(),void 0===t.threshold&&void 0===t.rootMargin&&void 0===t.root||(this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.setupVisibilityManager()),i&&this.config.enabled&&this.start()}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.container.style.transform=this.initialTransform||"",this.container.style.opacity="",this.container.style.transition=""}}const s=t.defineComponent({__name:"ScrollFadeIn",props:{className:{default:""},style:{default:()=>({})},direction:{default:"bottom"},distance:{default:"50px"},duration:{default:800},threshold:{default:.1},rootMargin:{default:"0px"},root:{default:null},triggerOnce:{type:Boolean,default:!1},enabled:{type:Boolean,default:!0},onStart:{type:Function,default:null},onComplete:{type:Function,default:null}},emits:["start","complete"],setup(i,{expose:e,emit:s}){const o=i,r=s,a=t.ref(null);let h=null;return t.watch(()=>[o.direction,o.distance,o.duration,o.threshold,o.rootMargin,o.root,o.triggerOnce,o.enabled],()=>{h&&h.updateConfig({direction:o.direction,distance:o.distance,duration:o.duration,threshold:o.threshold,rootMargin:o.rootMargin,root:o.root,triggerOnce:o.triggerOnce,enabled:o.enabled,onStart:()=>{o.onStart&&o.onStart(),r("start")},onComplete:()=>{o.onComplete&&o.onComplete(),r("complete")}})}),t.onMounted(()=>{(()=>{if(!a.value)return;const t={direction:o.direction,distance:o.distance,duration:o.duration,threshold:o.threshold,rootMargin:o.rootMargin,root:o.root,triggerOnce:o.triggerOnce,enabled:o.enabled,onStart:()=>{o.onStart&&o.onStart(),r("start")},onComplete:()=>{o.onComplete&&o.onComplete(),r("complete")}};h=new n(a.value,t)})()}),t.onBeforeUnmount(()=>{h&&(h.destroy(),h=null)}),e({start:()=>{h&&h.start()},stop:()=>{h&&h.stop()},reset:()=>{h&&h.reset()},updateConfig:t=>{h&&h.updateConfig(t)},destroy:()=>{h&&(h.destroy(),h=null)}}),(e,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:a,class:t.normalizeClass(i.className),style:t.normalizeStyle(i.style)},[t.renderSlot(e.$slots,"default")],6))}});module.exports=s;
1
+ "use strict";const t=require("vue");class i{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)}}const e=t=>--t*t*t+1;class n{constructor(t,i={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={direction:i.direction??"bottom",distance:i.distance??"50px",duration:i.duration??800,threshold:i.threshold??.1,rootMargin:i.rootMargin??"0px",root:i.root??null,triggerOnce:i.triggerOnce??!1,enabled:i.enabled??!0,onStart:i.onStart||null,onComplete:i.onComplete||null},this.easing=e,this.visibilityManager=null,this.animationFrameId=null,this.startTime=null,this.isRunning=!1,this.hasTriggered=!1,this.initialTransform="",this.targetDistance=0,this.init()}init(){const t=window.getComputedStyle(this.container);this.initialTransform="none"!==t.transform?t.transform:this.container.style.transform||"",this.targetDistance=this.parseDistance(this.config.distance),this.setInitialPosition(),this.setupVisibilityManager()}parseDistance(t){const i=t.match(/^(-?\d+\.?\d*)(px|rem|em|%|vh|vw)$/);if(!i){return parseFloat(t)||50}const e=parseFloat(i[1]);switch(i[2]){case"px":default:return e;case"rem":case"em":return e*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16);case"%":{const t=this.container.getBoundingClientRect();return e/100*("top"===this.config.direction||"bottom"===this.config.direction?t.height:t.width)}case"vh":return e/100*window.innerHeight;case"vw":return e/100*window.innerWidth}}setInitialPosition(){let t=0,i=0;switch(this.config.direction){case"top":i=-this.targetDistance;break;case"right":t=this.targetDistance;break;case"bottom":i=this.targetDistance;break;case"left":t=-this.targetDistance}const e=this.initialTransform||"",n=`translate(${t}px, ${i}px)`;this.container.style.transform=e&&"none"!==e?`${n} ${e}`:n,this.container.style.opacity="0",this.container.style.transition="none"}setupVisibilityManager(){this.visibilityManager=new i(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,root:this.config.root,onVisible:()=>{this.config.enabled&&(this.config.triggerOnce&&this.hasTriggered||(this.hasTriggered=!0,this.start()))},onHidden:()=>{this.config.enabled&&(this.stop(),this.config.triggerOnce||(this.hasTriggered=!1),this.setInitialPosition())}})}start(){this.isRunning||(this.isRunning=!0,this.startTime=performance.now(),this.config.onStart&&this.config.onStart(),this.container.style.transition="none",this.animate())}animate(){if(!this.isRunning)return;const t=performance.now()-(this.startTime||0),i=Math.min(t/this.config.duration,1),e=this.easing(i);let n=0,s=0;switch(this.config.direction){case"top":s=-this.targetDistance*(1-e);break;case"right":n=this.targetDistance*(1-e);break;case"bottom":s=this.targetDistance*(1-e);break;case"left":n=-this.targetDistance*(1-e)}const o=this.initialTransform||"",r=`translate(${n}px, ${s}px)`;this.container.style.transform=o&&"none"!==o?`${r} ${o}`:r,this.container.style.opacity=String(e),i<1?this.animationFrameId=requestAnimationFrame(()=>this.animate()):this.complete()}complete(){this.isRunning=!1,this.initialTransform&&"none"!==this.initialTransform?this.container.style.transform=this.initialTransform:this.container.style.transform="",this.container.style.opacity="1",this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.config.onComplete&&this.config.onComplete()}reset(){this.stop(),this.hasTriggered=!1,this.setInitialPosition()}stop(){this.isRunning=!1,this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}updateConfig(t){const i=this.isRunning;this.stop(),this.config={...this.config,...t,onStart:t.onStart??this.config.onStart,onComplete:t.onComplete??this.config.onComplete},t.distance&&(this.targetDistance=this.parseDistance(this.config.distance)),this.setInitialPosition(),void 0===t.threshold&&void 0===t.rootMargin&&void 0===t.root||(this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.setupVisibilityManager()),i&&this.config.enabled&&this.start()}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.container.style.transform=this.initialTransform||"",this.container.style.opacity="",this.container.style.transition=""}}const s=t.defineComponent({__name:"ScrollFadeIn",props:{className:{default:""},style:{default:()=>({})},direction:{default:"bottom"},distance:{default:"50px"},duration:{default:800},threshold:{default:.1},rootMargin:{default:"0px"},root:{default:null},triggerOnce:{type:Boolean,default:!1},enabled:{type:Boolean,default:!0},onStart:{type:Function,default:null},onComplete:{type:Function,default:null}},emits:["start","complete"],setup(i,{expose:e,emit:s}){const o=i,r=s,a=t.ref(null);let h=null;return t.watch(()=>[o.direction,o.distance,o.duration,o.threshold,o.rootMargin,o.root,o.triggerOnce,o.enabled],()=>{h&&h.updateConfig({direction:o.direction,distance:o.distance,duration:o.duration,threshold:o.threshold,rootMargin:o.rootMargin,root:o.root,triggerOnce:o.triggerOnce,enabled:o.enabled,onStart:()=>{o.onStart&&o.onStart(),r("start")},onComplete:()=>{o.onComplete&&o.onComplete(),r("complete")}})}),t.onMounted(()=>{(()=>{if(!a.value)return;const t={direction:o.direction,distance:o.distance,duration:o.duration,threshold:o.threshold,rootMargin:o.rootMargin,root:o.root,triggerOnce:o.triggerOnce,enabled:o.enabled,onStart:()=>{o.onStart&&o.onStart(),r("start")},onComplete:()=>{o.onComplete&&o.onComplete(),r("complete")}};h=new n(a.value,t)})()}),t.onBeforeUnmount(()=>{h&&(h.destroy(),h=null)}),e({start:()=>{h&&h.start()},stop:()=>{h&&h.stop()},reset:()=>{h&&h.reset()},updateConfig:t=>{h&&h.updateConfig(t)},destroy:()=>{h&&(h.destroy(),h=null)}}),(e,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:a,class:t.normalizeClass(i.className),style:t.normalizeStyle(i.style)},[t.renderSlot(e.$slots,"default")],6))}});module.exports=s;
@@ -154,13 +154,15 @@ class ScrollFadeIn {
154
154
  case "px":
155
155
  return value;
156
156
  case "rem":
157
- case "em":
157
+ case "em": {
158
158
  const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
159
159
  return value * fontSize;
160
- case "%":
160
+ }
161
+ case "%": {
161
162
  const rect = this.container.getBoundingClientRect();
162
163
  const dimension = this.config.direction === "top" || this.config.direction === "bottom" ? rect.height : rect.width;
163
164
  return value / 100 * dimension;
165
+ }
164
166
  case "vh":
165
167
  return value / 100 * window.innerHeight;
166
168
  case "vw":
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue");class e{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)}}class i{constructor(t,e){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");if(!e.text)throw new Error("Text is required");this.config={text:e.text,delay:e.delay??.2,duration:e.duration??.6,randomDelay:e.randomDelay??2,threshold:e.threshold??.1,rootMargin:e.rootMargin??"0px",root:e.root??null,triggerOnce:e.triggerOnce??!1,enabled:e.enabled??!0,onStart:e.onStart||null,onComplete:e.onComplete||null},this.visibilityManager=null,this.textElements=[],this.randomPoints=[],this.hasTriggered=!1,this.isActive=!1,this.init()}init(){this.injectStyles(),this.createTextStructure(),this.setupVisibilityManager()}injectStyles(){if(document.getElementById("masoneffect-textspin-styles"))return;const t=document.createElement("style");t.id="masoneffect-textspin-styles",t.textContent="\n .masoneffect-textspin {\n display: inline-block;\n }\n .masoneffect-textspin-char {\n display: inline-block;\n opacity: 0;\n transform: rotateY(90deg);\n }\n .masoneffect-textspin-char.active {\n opacity: 1;\n transform: rotateY(0deg);\n }\n .masoneffect-textspin-char.space {\n width: 0.25em;\n }\n ",document.head.appendChild(t)}createTextStructure(){this.container.innerHTML="",this.textElements=[],this.randomPoints=[];const t=this.config.text.split("");t.forEach(()=>{this.randomPoints.push(Math.random())}),t.forEach((t,e)=>{const i=document.createElement("span");i.className="masoneffect-textspin-char",i.style.transition=`opacity ${this.config.duration}s ease-out, transform ${this.config.duration}s ease-out`," "===t?(i.classList.add("space"),i.innerHTML="&nbsp;"):i.textContent=t,this.container.appendChild(i),this.textElements.push(i)}),this.container.classList.add("masoneffect-textspin")}setupVisibilityManager(){this.visibilityManager=new e(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,root:this.config.root,onVisible:()=>{this.config.enabled&&(this.config.triggerOnce&&this.hasTriggered||(this.hasTriggered=!0,this.start()))},onHidden:()=>{this.config.enabled&&(this.stop(),this.config.triggerOnce||(this.hasTriggered=!1))}})}start(){if(this.isActive)return;this.isActive=!0,this.config.onStart&&this.config.onStart(),this.textElements.forEach((t,e)=>{const i=this.config.delay+this.randomPoints[e]*this.config.randomDelay;t.style.transitionDelay=`${i}s`,requestAnimationFrame(()=>{t.classList.add("active")})});const t=this.config.delay+this.config.randomDelay+this.config.duration;setTimeout(()=>{this.config.onComplete&&this.config.onComplete()},1e3*t)}stop(){this.isActive&&(this.isActive=!1,this.textElements.forEach(t=>{t.classList.remove("active"),t.style.transitionDelay=""}))}reset(){this.stop(),this.hasTriggered=!1}updateText(t){this.config.text=t,this.createTextStructure(),this.isActive&&this.start()}updateTransitions(){this.textElements.forEach(t=>{t.style.transition=`opacity ${this.config.duration}s ease-out, transform ${this.config.duration}s ease-out`})}updateConfig(t){var e;const i=this.isActive;this.config.enabled;const n=void 0!==t.enabled&&t.enabled!==this.config.enabled;(n&&!1===t.enabled||i)&&this.stop(),this.config={...this.config,...t,text:t.text??this.config.text,onStart:t.onStart??this.config.onStart,onComplete:t.onComplete??this.config.onComplete},void 0!==t.text?this.createTextStructure():void 0!==t.duration&&this.updateTransitions(),void 0===t.threshold&&void 0===t.rootMargin&&void 0===t.root||(this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.setupVisibilityManager()),this.config.enabled&&(i||n&&!0===t.enabled)&&(null==(e=this.visibilityManager)?void 0:e.getIsVisible())&&this.start()}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.container.innerHTML="",this.container.classList.remove("masoneffect-textspin")}}const n=t.defineComponent({__name:"TextSpin",props:{className:{default:""},style:{default:()=>({})},onStart:{type:Function,default:null},onComplete:{type:Function,default:null},text:{default:""},delay:{default:.2},duration:{default:.6},randomDelay:{default:2},threshold:{default:.1},rootMargin:{default:"0px"},root:{default:null},triggerOnce:{type:Boolean,default:!1},enabled:{type:Boolean,default:!0}},emits:["start","complete"],setup(e,{expose:n,emit:s}){const o=e,r=s,a=t.ref(null);let l=null;return t.onMounted(()=>{(()=>{if(!a.value)return;const t={text:o.text,delay:o.delay,duration:o.duration,randomDelay:o.randomDelay,threshold:o.threshold,rootMargin:o.rootMargin,root:o.root,triggerOnce:o.triggerOnce,enabled:o.enabled,onStart:()=>{o.onStart&&o.onStart(),r("start")},onComplete:()=>{o.onComplete&&o.onComplete(),r("complete")}};l=new i(a.value,t)})()}),t.onBeforeUnmount(()=>{l&&(l.destroy(),l=null)}),t.watch(()=>[o.text,o.delay,o.duration,o.randomDelay,o.threshold,o.rootMargin,o.root,o.triggerOnce,o.enabled,o.onStart,o.onComplete],()=>{l&&l.updateConfig({text:o.text,delay:o.delay,duration:o.duration,randomDelay:o.randomDelay,threshold:o.threshold,rootMargin:o.rootMargin,root:o.root,triggerOnce:o.triggerOnce,enabled:o.enabled,onStart:o.onStart||void 0,onComplete:o.onComplete||void 0})},{deep:!0}),n({start:()=>{l&&l.start()},stop:()=>{l&&l.stop()},reset:()=>{l&&l.reset()},updateText:t=>{l&&l.updateText(t)},updateConfig:t=>{l&&l.updateConfig(t)},destroy:()=>{l&&(l.destroy(),l=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:a,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},null,6))}});exports.TextSpin=i,exports.default=n;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue");class e{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)}}class i{constructor(t,e){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");if(!e.text)throw new Error("Text is required");this.config={text:e.text,delay:e.delay??.2,duration:e.duration??.6,randomDelay:e.randomDelay??2,threshold:e.threshold??.1,rootMargin:e.rootMargin??"0px",root:e.root??null,triggerOnce:e.triggerOnce??!1,enabled:e.enabled??!0,onStart:e.onStart||null,onComplete:e.onComplete||null},this.visibilityManager=null,this.textElements=[],this.randomPoints=[],this.hasTriggered=!1,this.isActive=!1,this.init()}init(){this.injectStyles(),this.createTextStructure(),this.setupVisibilityManager()}injectStyles(){if(document.getElementById("masoneffect-textspin-styles"))return;const t=document.createElement("style");t.id="masoneffect-textspin-styles",t.textContent="\n .masoneffect-textspin {\n display: inline-block;\n }\n .masoneffect-textspin-char {\n display: inline-block;\n opacity: 0;\n transform: rotateY(90deg);\n }\n .masoneffect-textspin-char.active {\n opacity: 1;\n transform: rotateY(0deg);\n }\n .masoneffect-textspin-char.space {\n width: 0.25em;\n }\n ",document.head.appendChild(t)}createTextStructure(){this.container.innerHTML="",this.textElements=[],this.randomPoints=[];const t=this.config.text.split("");t.forEach(()=>{this.randomPoints.push(Math.random())}),t.forEach(t=>{const e=document.createElement("span");e.className="masoneffect-textspin-char",e.style.transition=`opacity ${this.config.duration}s ease-out, transform ${this.config.duration}s ease-out`," "===t?(e.classList.add("space"),e.innerHTML="&nbsp;"):e.textContent=t,this.container.appendChild(e),this.textElements.push(e)}),this.container.classList.add("masoneffect-textspin")}setupVisibilityManager(){this.visibilityManager=new e(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,root:this.config.root,onVisible:()=>{this.config.enabled&&(this.config.triggerOnce&&this.hasTriggered||(this.hasTriggered=!0,this.start()))},onHidden:()=>{this.config.enabled&&(this.stop(),this.config.triggerOnce||(this.hasTriggered=!1))}})}start(){if(this.isActive)return;this.isActive=!0,this.config.onStart&&this.config.onStart(),this.textElements.forEach((t,e)=>{const i=this.config.delay+this.randomPoints[e]*this.config.randomDelay;t.style.transitionDelay=`${i}s`,requestAnimationFrame(()=>{t.classList.add("active")})});const t=this.config.delay+this.config.randomDelay+this.config.duration;setTimeout(()=>{this.config.onComplete&&this.config.onComplete()},1e3*t)}stop(){this.isActive&&(this.isActive=!1,this.textElements.forEach(t=>{t.classList.remove("active"),t.style.transitionDelay=""}))}reset(){this.stop(),this.hasTriggered=!1}updateText(t){this.config.text=t,this.createTextStructure(),this.isActive&&this.start()}updateTransitions(){this.textElements.forEach(t=>{t.style.transition=`opacity ${this.config.duration}s ease-out, transform ${this.config.duration}s ease-out`})}updateConfig(t){var e;const i=this.isActive,n=void 0!==t.enabled&&t.enabled!==this.config.enabled;(n&&!1===t.enabled||i)&&this.stop(),this.config={...this.config,...t,text:t.text??this.config.text,onStart:t.onStart??this.config.onStart,onComplete:t.onComplete??this.config.onComplete},void 0!==t.text?this.createTextStructure():void 0!==t.duration&&this.updateTransitions(),void 0===t.threshold&&void 0===t.rootMargin&&void 0===t.root||(this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.setupVisibilityManager()),this.config.enabled&&(i||n&&!0===t.enabled)&&(null==(e=this.visibilityManager)?void 0:e.getIsVisible())&&this.start()}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null),this.container.innerHTML="",this.container.classList.remove("masoneffect-textspin")}}const n=t.defineComponent({__name:"TextSpin",props:{className:{default:""},style:{default:()=>({})},onStart:{type:Function,default:null},onComplete:{type:Function,default:null},text:{default:""},delay:{default:.2},duration:{default:.6},randomDelay:{default:2},threshold:{default:.1},rootMargin:{default:"0px"},root:{default:null},triggerOnce:{type:Boolean,default:!1},enabled:{type:Boolean,default:!0}},emits:["start","complete"],setup(e,{expose:n,emit:s}){const o=e,r=s,a=t.ref(null);let l=null;return t.onMounted(()=>{(()=>{if(!a.value)return;const t={text:o.text,delay:o.delay,duration:o.duration,randomDelay:o.randomDelay,threshold:o.threshold,rootMargin:o.rootMargin,root:o.root,triggerOnce:o.triggerOnce,enabled:o.enabled,onStart:()=>{o.onStart&&o.onStart(),r("start")},onComplete:()=>{o.onComplete&&o.onComplete(),r("complete")}};l=new i(a.value,t)})()}),t.onBeforeUnmount(()=>{l&&(l.destroy(),l=null)}),t.watch(()=>[o.text,o.delay,o.duration,o.randomDelay,o.threshold,o.rootMargin,o.root,o.triggerOnce,o.enabled,o.onStart,o.onComplete],()=>{l&&l.updateConfig({text:o.text,delay:o.delay,duration:o.duration,randomDelay:o.randomDelay,threshold:o.threshold,rootMargin:o.rootMargin,root:o.root,triggerOnce:o.triggerOnce,enabled:o.enabled,onStart:o.onStart||void 0,onComplete:o.onComplete||void 0})},{deep:!0}),n({start:()=>{l&&l.start()},stop:()=>{l&&l.stop()},reset:()=>{l&&l.reset()},updateText:t=>{l&&l.updateText(t)},updateConfig:t=>{l&&l.updateConfig(t)},destroy:()=>{l&&(l.destroy(),l=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:a,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},null,6))}});exports.TextSpin=i,exports.default=n;
@@ -171,7 +171,7 @@ class TextSpin {
171
171
  chars.forEach(() => {
172
172
  this.randomPoints.push(Math.random());
173
173
  });
174
- chars.forEach((char, index) => {
174
+ chars.forEach((char) => {
175
175
  const charElement = document.createElement("span");
176
176
  charElement.className = "masoneffect-textspin-char";
177
177
  charElement.style.transition = `opacity ${this.config.duration}s ease-out, transform ${this.config.duration}s ease-out`;
@@ -259,7 +259,6 @@ class TextSpin {
259
259
  updateConfig(newConfig) {
260
260
  var _a;
261
261
  const wasActive = this.isActive;
262
- this.config.enabled;
263
262
  const isEnabledChanging = newConfig.enabled !== void 0 && newConfig.enabled !== this.config.enabled;
264
263
  if (isEnabledChanging && newConfig.enabled === false) {
265
264
  this.stop();
@@ -1 +1 @@
1
- "use strict";const t=require("vue");class i{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 e(t,i){let e=null;return function(...s){null!==e&&clearTimeout(e),e=setTimeout(()=>{e=null,t.apply(this,s)},i)}}class s{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 s=this.canvas.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("Canvas context not available");this.ctx=s,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 o=this.handleResize.bind(this);this.handleResize=e(o,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=e(this._morphInternal.bind(this),this.debounceDelay),this._debouncedUpdateConfig=e(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 i(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 s=4096;if(this.W>s||this.H>s){const t=Math.min(s/this.W,s/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,s){this.offCtx.font=`400 ${t}px ${this.config.fontFamily}`;const n=i.split("\n"),o=t,h=.1*t,a=.05*t;let l=0;for(const d of n){if(0===d.length)continue;const t=this.offCtx.measureText(d).width+a*(d.length>0?d.length-1:0);l=Math.max(l,t)}const r=n.length>0?o*n.length+h*(n.length-1):o;return{width:l,height:r,fits:l<=e&&r<=s}}findOptimalFontSize(t,i,e,s){if(this.measureTextFit(s,t,i,e).fits)return s;if(s<=12)return 12;let n=12,o=s,h=12;for(;n<=o;){const s=Math.floor((n+o)/2);this.measureTextFit(s,t,i,e).fits?(h=s,n=s+1):o=s-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)),s=this.W-80,n=this.H-80,o=this.findOptimalFontSize(t,s,n,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,l=.1*o,r=.05*o,d=h.length>0?a*h.length+l*(h.length-1):a;let c=this.H/2-d/2+a/2;for(const g of h){if(0===g.length){c+=a+l;continue}const t=g.split(""),i=this.offCtx.measureText(g).width+r*(t.length>0?t.length-1:0);let e=this.W/2-i/2;for(const s of t)this.offCtx.fillText(s,e+this.offCtx.measureText(s).width/2,c),e+=this.offCtx.measureText(s).width+r;c+=a+l}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 s of this.particles){let t=(s.tx-s.x)*this.config.ease,i=(s.ty-s.y)*this.config.ease;if(this.mouse.x||this.mouse.y){const e=s.x-this.mouse.x,n=s.y-this.mouse.y,o=e*e+n*n,h=this.config.repelRadius*this.DPR;if(o<h*h){const s=Math.sqrt(o)+1e-4,a=(this.mouse.down?-1:1)*this.config.repelStrength*(1-s/h);t+=e/s*a*6,i+=n/s*a*6}}s.j+=2,t+=.05*Math.cos(s.j),i+=.05*Math.sin(1.3*s.j),s.vx=(s.vx+t)*Math.random(),s.vy=(s.vy+i)*Math.random(),s.x+=s.vx,s.y+=s.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 s of this.particles)this.ctx.beginPath(),this.ctx.arc(s.x,s.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)}}const n=t.defineComponent({__name:"TextToParticle",props:{className:{default:""},style:{default:()=>({})},text:{default:"mason effect"},densityStep:{default:2},maxParticles:{default:3200},pointSize:{default:.5},ease:{default:.05},repelRadius:{default:150},repelStrength:{default:1},particleColor:{default:"#fff"},fontFamily:{default:"Inter, system-ui, Arial"},fontSize:{default:null},width:{default:null},height:{default:null},devicePixelRatio:{default:null},debounceDelay:{},onReady:{type:Function,default:null},onUpdate:{type:Function,default:null}},emits:["ready","update"],setup(i,{expose:e,emit:n}){const o=i,h=n,a=t.ref(null);let l=null;return t.watch(()=>[o.text,o.densityStep,o.maxParticles,o.pointSize,o.ease,o.repelRadius,o.repelStrength,o.particleColor,o.fontFamily,o.fontSize,o.width,o.height,o.devicePixelRatio],()=>{l&&l.updateConfig({text:o.text,densityStep:o.densityStep,maxParticles:o.maxParticles,pointSize:o.pointSize,ease:o.ease,repelRadius:o.repelRadius,repelStrength:o.repelStrength,particleColor:o.particleColor,fontFamily:o.fontFamily,fontSize:o.fontSize,width:o.width,height:o.height,devicePixelRatio:o.devicePixelRatio})}),t.onMounted(()=>{(()=>{if(!a.value)return;const t={text:o.text,densityStep:o.densityStep,maxParticles:o.maxParticles,pointSize:o.pointSize,ease:o.ease,repelRadius:o.repelRadius,repelStrength:o.repelStrength,particleColor:o.particleColor,fontFamily:o.fontFamily,fontSize:o.fontSize,width:o.width,height:o.height,devicePixelRatio:o.devicePixelRatio,onReady:t=>{o.onReady&&o.onReady(t),h("ready",t)},onUpdate:t=>{o.onUpdate&&o.onUpdate(t),h("update",t)}};l=new s(a.value,t)})()}),t.onBeforeUnmount(()=>{l&&(l.destroy(),l=null)}),e({morph:t=>{l&&l.morph(t)},scatter:()=>{l&&l.scatter()},updateConfig:t=>{l&&l.updateConfig(t)},destroy:()=>{l&&(l.destroy(),l=null)}}),(e,s)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:a,class:t.normalizeClass(i.className),style:t.normalizeStyle(i.style)},null,6))}});module.exports=n;
1
+ "use strict";const t=require("vue");class e{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,e){let i=null;return function(...s){null!==i&&clearTimeout(i),i=setTimeout(()=>{i=null,t.apply(this,s)},e)}}class s{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 s=this.canvas.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("Canvas context not available");this.ctx=s,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 o=this.handleResize.bind(this);this.handleResize=i(o,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=i(this._morphInternal.bind(this),this.debounceDelay),this._debouncedUpdateConfig=i(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 e(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 s=4096;if(this.W>s||this.H>s){const t=Math.min(s/this.W,s/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,s){this.offCtx.font=`400 ${t}px ${this.config.fontFamily}`;const n=e.split("\n"),o=t,h=.1*t,a=.05*t;let l=0;for(const d of n){if(0===d.length)continue;const t=this.offCtx.measureText(d).width+a*(d.length>0?d.length-1:0);l=Math.max(l,t)}const r=n.length>0?o*n.length+h*(n.length-1):o;return{width:l,height:r,fits:l<=i&&r<=s}}findOptimalFontSize(t,e,i,s){if(this.measureTextFit(s,t,e,i).fits)return s;if(s<=12)return 12;let n=12,o=s,h=12;for(;n<=o;){const s=Math.floor((n+o)/2);this.measureTextFit(s,t,e,i).fits?(h=s,n=s+1):o=s-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)),s=this.W-80,n=this.H-80,o=this.findOptimalFontSize(t,s,n,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,l=.1*o,r=.05*o,d=h.length>0?a*h.length+l*(h.length-1):a;let c=this.H/2-d/2+a/2;for(const v of h){if(0===v.length){c+=a+l;continue}const t=v.split(""),e=this.offCtx.measureText(v).width+r*(t.length>0?t.length-1:0);let i=this.W/2-e/2;for(const s of t)this.offCtx.fillText(s,i+this.offCtx.measureText(s).width/2,c),i+=this.offCtx.measureText(s).width+r;c+=a+l}const u=Math.max(2,this.config.densityStep),f=this.offCtx.getImageData(0,0,this.W,this.H).data,p=[];for(let v=0;v<this.H;v+=u)for(let t=0;t<this.W;t+=u){const e=4*(v*this.W+t);f[e]+f[e+1]+f[e+2]>600&&p.push({x:t,y:v})}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 v=0;v<this.particles.length;v++){const t=this.particles[v],e=p[v];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 s of this.particles){let t=(s.tx-s.x)*this.config.ease,e=(s.ty-s.y)*this.config.ease;if(this.mouse.x||this.mouse.y){const i=s.x-this.mouse.x,n=s.y-this.mouse.y,o=i*i+n*n,h=this.config.repelRadius*this.DPR;if(o<h*h){const s=Math.sqrt(o)+1e-4,a=(this.mouse.down?-1:1)*this.config.repelStrength*(1-s/h);t+=i/s*a*6,e+=n/s*a*6}}s.j+=2,t+=.05*Math.cos(s.j),e+=.05*Math.sin(1.3*s.j),s.vx=(s.vx+t)*Math.random(),s.vy=(s.vy+e)*Math.random(),s.x+=s.vx,s.y+=s.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 s of this.particles)this.ctx.beginPath(),this.ctx.arc(s.x,s.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)}}const n=t.defineComponent({__name:"TextToParticle",props:{className:{default:""},style:{default:()=>({})},text:{default:"mason effect"},densityStep:{default:2},maxParticles:{default:3200},pointSize:{default:.5},ease:{default:.05},repelRadius:{default:150},repelStrength:{default:1},particleColor:{default:"#fff"},fontFamily:{default:"Inter, system-ui, Arial"},fontSize:{default:null},width:{default:null},height:{default:null},devicePixelRatio:{default:null},debounceDelay:{},onReady:{type:Function,default:null},onUpdate:{type:Function,default:null}},emits:["ready","update"],setup(e,{expose:i,emit:n}){const o=e,h=n,a=t.ref(null);let l=null,r=null,d=null,c=null;const u=t.computed(()=>({width:"100%",height:"100%",minHeight:300,position:"relative",...o.style})),f=()=>{if(!a.value)return;if(l)return;const t=a.value.querySelector("canvas");t&&t.remove();const e=a.value.getBoundingClientRect();if(!(e.width>0&&e.height>0)){if("undefined"!=typeof ResizeObserver){let t=0;const e=20;return d&&(d.disconnect(),d=null),d=new ResizeObserver(()=>{var i;t++;const s=null==(i=a.value)?void 0:i.getBoundingClientRect();(s&&s.width>0&&s.height>0||t>=e)&&(d&&(d.disconnect(),d=null),f())}),void d.observe(a.value)}return void(c=window.setTimeout(f,50))}const i={text:o.text,densityStep:o.densityStep,maxParticles:o.maxParticles,pointSize:o.pointSize,ease:o.ease,repelRadius:o.repelRadius,repelStrength:o.repelStrength,particleColor:o.particleColor,fontFamily:o.fontFamily,fontSize:o.fontSize,width:o.width,height:o.height,devicePixelRatio:o.devicePixelRatio,onReady:t=>{o.onReady&&o.onReady(t),h("ready",t)},onUpdate:t=>{o.onUpdate&&o.onUpdate(t),h("update",t)}};l=new s(a.value,i),"undefined"!=typeof ResizeObserver&&(r=new ResizeObserver(()=>{l&&l.resize()}),r.observe(a.value))};return t.watch(()=>[o.text,o.densityStep,o.maxParticles,o.pointSize,o.ease,o.repelRadius,o.repelStrength,o.particleColor,o.fontFamily,o.fontSize,o.width,o.height,o.devicePixelRatio],()=>{l&&l.updateConfig({text:o.text,densityStep:o.densityStep,maxParticles:o.maxParticles,pointSize:o.pointSize,ease:o.ease,repelRadius:o.repelRadius,repelStrength:o.repelStrength,particleColor:o.particleColor,fontFamily:o.fontFamily,fontSize:o.fontSize,width:o.width,height:o.height,devicePixelRatio:o.devicePixelRatio})}),t.onMounted(()=>{requestAnimationFrame(f)}),t.onBeforeUnmount(()=>{c&&(clearTimeout(c),c=null),d&&(d.disconnect(),d=null),r&&(r.disconnect(),r=null),l&&(l.destroy(),l=null)}),i({morph:t=>{l&&l.morph(t)},scatter:()=>{l&&l.scatter()},updateConfig:t=>{l&&l.updateConfig(t)},destroy:()=>{l&&(l.destroy(),l=null)}}),(i,s)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:a,class:t.normalizeClass(e.className),style:t.normalizeStyle(u.value)},null,6))}});module.exports=n;