Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit dd8bb13

Browse files
committed
Fix parseTransition bug
1 parent 6d9e4e5 commit dd8bb13

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/utils/parseTransition.spec.ts

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ describe("parseTransition", () => {
1919
{ property: "height", duration: 3000, delay: 2000 },
2020
],
2121
],
22+
[
23+
"transform 100ms cubic-bezier(0.4, 0.0, 0.6, 1) 150ms",
24+
[
25+
{ property: "transform", duration: 100, delay: 150 },
26+
{ property: "transform", duration: 100, delay: 150 },
27+
],
28+
],
2229
];
2330
cases.forEach((c) => assert.deepEqual(parseTransition(c[0] as string), c[1]));
2431
});

src/utils/parseTransition.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ export function parseTransition(transition: string): [TransitionEntry, Transitio
1111
let firstProperty: TransitionEntry = null;
1212
let lastPropertyTotalDuration = -1;
1313
let firstPropertyDelay = 99999999;
14-
transition.split(/\s*,\s*/).forEach(
14+
transition.split(/\s*,\s*(?![^\(]*\))/g).forEach(
1515
(entry) => {
16-
const parts = entry.split(/\s+/);
16+
const parts = entry.split(/\s+(?![^\(]*\))/g);
1717
const property = parts.filter((p) => p.match(/^[a-z\-A-Z]+$/))[0];
1818
const [duration = 0, delay = 0] = parts.filter((p) => p.match(/^[0-9]+m?s$/)).map((p) => parseDuration(p));
1919
const totalDuration = duration + delay;

0 commit comments

Comments
 (0)