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

Commit

Permalink
feat: Add applyCssTransform function (#170)
Browse files Browse the repository at this point in the history
* Applies a CSS transform to an element.
  • Loading branch information
trimox authored Sep 13, 2017
1 parent c5434d8 commit 4115006
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './events';
export * from './keycodes';
export * from './number-property';
export * from './platform';
export * from './style/index';
13 changes: 13 additions & 0 deletions src/lib/common/style/apply-transform.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Applies a CSS transform to an element, including browser-prefixed properties.
* @param element
* @param transformValue
*/
export function applyCssTransform(element: HTMLElement, transformValue: string) {
// It's important to trim the result, because the browser will ignore the set operation
// if the string contains only whitespace.
let value = transformValue.trim();

element.style.transform = value;
element.style.webkitTransform = value;
}
1 change: 1 addition & 0 deletions src/lib/common/style/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './apply-transform';

0 comments on commit 4115006

Please sign in to comment.