This repository has been archived by the owner on Oct 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add applyCssTransform function (#170)
* Applies a CSS transform to an element.
- Loading branch information
Showing
3 changed files
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './apply-transform'; |