Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Oct 15, 2018
1 parent ea84482 commit 3484ed6
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/cssTransform.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
interface CssTransform {
(el: HTMLElement, transformRule: string, transitionRule: string): void,
/**
* 停止 CSS 变换。
*
* @param el 要停止变换的元素
*/
stop(el: HTMLElement): void
}

/**
* CSS 变换。
*
* @param el 要变换的元素
* @param transformRule 变换规则
* @param transitionRule 过渡规则
*/
function cssTransform(el: HTMLElement, transformRule: string, transitionRule: string): void {
const cssTransform: CssTransform = (el: HTMLElement, transformRule: string, transitionRule: string): void => {
el.style.webkitTransform = transformRule
el.style.transform = transformRule
el.style.webkitTransition = `-webkit-transform ${transitionRule}`
el.style.transition = `transform ${transitionRule}`
}

/**
* 停止 CSS 变换。
*
* @param el 要停止变换的元素
*/
function stop(el: HTMLElement): void {
cssTransform.stop = (el: HTMLElement): void => {
el.style.webkitTransition = 'none'
el.style.transition = 'none'
}

cssTransform.stop = stop

export default cssTransform

0 comments on commit 3484ed6

Please sign in to comment.