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

Commit 4115006

Browse files
authored
feat: Add applyCssTransform function (#170)
* Applies a CSS transform to an element.
1 parent c5434d8 commit 4115006

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/lib/common/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from './events';
33
export * from './keycodes';
44
export * from './number-property';
55
export * from './platform';
6+
export * from './style/index';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Applies a CSS transform to an element, including browser-prefixed properties.
3+
* @param element
4+
* @param transformValue
5+
*/
6+
export function applyCssTransform(element: HTMLElement, transformValue: string) {
7+
// It's important to trim the result, because the browser will ignore the set operation
8+
// if the string contains only whitespace.
9+
let value = transformValue.trim();
10+
11+
element.style.transform = value;
12+
element.style.webkitTransform = value;
13+
}

src/lib/common/style/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './apply-transform';

0 commit comments

Comments
 (0)