Skip to content

Commit

Permalink
fix: Ellipsis optimize line height caculation (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
TinaPeach authored Jan 31, 2024
1 parent cbb761f commit c791a8e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ResizeObserver from 'resize-observer-polyfill';

import { JsEllipsisProps, JsEllipsisRef } from '../type';
import { getLineHeight, wrapTextChildNodesWithSpan } from '../utils/dom';
import { useLatestRef } from '../../_helpers';

const JsEllipsis = forwardRef((props: JsEllipsisProps, ref: Ref<JsEllipsisRef>) => {
const {
Expand All @@ -24,13 +25,12 @@ const JsEllipsis = forwardRef((props: JsEllipsisProps, ref: Ref<JsEllipsisRef>)
const domRef = useRef<HTMLDivElement>(null);
const textRef = useRef<HTMLSpanElement>(null);
const ellipsisRef = useRef<HTMLSpanElement>(null);
const ellipsisValueRef = useRef(ellipsis);
ellipsisValueRef.current = ellipsis;
const ellipsisValueRef = useLatestRef(ellipsis);

const lineHeightRef = useRef(0);
const setCurLineHeight = useCallback(() => {
if (domRef.current) {
lineHeightRef.current = getLineHeight(domRef.current);
lineHeightRef.current = Math.round(getLineHeight(domRef.current));
}
}, []);
useEffect(() => {
Expand Down
1 change: 0 additions & 1 deletion packages/common-widgets/utils/bezier-easing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const SUBDIVISION_MAX_ITERATIONS = 10;

const kSplineTableSize = 11;
const kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);

const float32ArraySupported = typeof Float32Array === 'function';

function A(aA1: number, aA2: number) {
Expand Down

0 comments on commit c791a8e

Please sign in to comment.