-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from tcjr/make-utils-public
Make utility functions importable
- Loading branch information
Showing
3 changed files
with
48 additions
and
1 deletion.
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,27 @@ | ||
/** | ||
* Function that returns a promise that resolves after `ms` milliseconds | ||
* | ||
* @function sleep | ||
* @param {number} ms number of milliseconds to wait | ||
* @return {Promise<void>} the promise | ||
*/ | ||
export function sleep(ms: number): Promise<void>; | ||
|
||
/** | ||
* Computes the time a css animation will take. | ||
* Uses `getComputedStyle` to get durations and delays. | ||
* | ||
* @function computeTimeout | ||
* @param {Element} element element used calculate the animation duration based on `getComputedStyle` | ||
* @return {number} the calculated animation duration + delay | ||
*/ | ||
export function computeTimeout(element: Element): number; | ||
|
||
/** | ||
* Function that returns a promise that resolves after DOM changes | ||
* have been flushed and after a browser repaint. | ||
* | ||
* @function nextTick | ||
* @return {Promise<void>} the promise | ||
*/ | ||
export function nextTick(): Promise<void>; |
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,20 @@ | ||
import { module, test } from 'qunit'; | ||
import { | ||
computeTimeout, | ||
nextTick, | ||
sleep, | ||
} from 'ember-css-transitions/utils/transition-utils'; | ||
|
||
module('Unit | Utility | transition-utils', function () { | ||
test('nextTick exists', function (assert) { | ||
assert.strictEqual(typeof nextTick, 'function'); | ||
}); | ||
|
||
test('sleep exists', function (assert) { | ||
assert.strictEqual(typeof sleep, 'function'); | ||
}); | ||
|
||
test('computeTimeout exists', function (assert) { | ||
assert.strictEqual(typeof computeTimeout, 'function'); | ||
}); | ||
}); |