fetta 1.3.2 → 1.3.3

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.
@@ -640,6 +640,26 @@ function performSplit(element, measuredWords, charClass, wordClass, lineClass, s
640
640
  targetElement.style.marginLeft = `${totalKerning}px`;
641
641
  }
642
642
  }
643
+ } else if (splitWords && allWords.length > 1) {
644
+ for (let wordIdx = 1; wordIdx < allWords.length; wordIdx++) {
645
+ if (noSpaceBeforeSet.has(allWords[wordIdx])) continue;
646
+ const prevWord = allWords[wordIdx - 1];
647
+ const currWord = allWords[wordIdx];
648
+ const prevText = prevWord.textContent || "";
649
+ const currText = currWord.textContent || "";
650
+ if (!prevText || !currText) continue;
651
+ const lastChar = prevText[prevText.length - 1];
652
+ const firstChar = currText[0];
653
+ const styles = getComputedStyle(currWord);
654
+ const kerningMap = measureKerning(element, currWord, [lastChar, " ", firstChar], styles);
655
+ let totalKerning = 0;
656
+ if (kerningMap.has(1)) totalKerning += kerningMap.get(1);
657
+ if (kerningMap.has(2)) totalKerning += kerningMap.get(2);
658
+ if (Math.abs(totalKerning) > 0.01 && Math.abs(totalKerning) < 20) {
659
+ const targetElement = (options == null ? void 0 : options.mask) === "words" && currWord.parentElement ? currWord.parentElement : currWord;
660
+ targetElement.style.marginLeft = `${totalKerning}px`;
661
+ }
662
+ }
643
663
  }
644
664
  if (splitLines) {
645
665
  const lineGroups = groupIntoLines(allWords, element);
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { splitText } from './chunk-INF3II55.js';
1
+ export { splitText } from './chunk-RJ7GQ53Y.js';
package/dist/react.js CHANGED
@@ -1,4 +1,4 @@
1
- import { splitText, __spreadProps, __spreadValues, normalizeToPromise } from './chunk-INF3II55.js';
1
+ import { splitText, __spreadProps, __spreadValues, normalizeToPromise } from './chunk-RJ7GQ53Y.js';
2
2
  import { forwardRef, useRef, useCallback, useState, useLayoutEffect, useEffect, isValidElement, cloneElement } from 'react';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fetta",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Text splitting library with kerning compensation for animations",
5
5
  "type": "module",
6
6
  "sideEffects": false,