Skip to content

Commit

Permalink
Merge pull request #138 from tcjr/make-utils-public
Browse files Browse the repository at this point in the history
Make utility functions importable
  • Loading branch information
SergeAstapov authored Oct 12, 2024
2 parents c2c9b73 + f30ffdf commit 0852867
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ember-css-transitions/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default {
plugins: [
// These are the modules that users should be able to import from your
// addon. Anything not listed here may get optimized away.
addon.publicEntrypoints(['modifiers/**/*.js', 'index.js']),
addon.publicEntrypoints(['modifiers/**/*.js', 'utils/**/*.js', 'index.js']),

// These are the modules that should get reexported into the traditional
// "app" tree. Things in here should also be in publicEntrypoints above, but
Expand Down
27 changes: 27 additions & 0 deletions ember-css-transitions/types/utils/transition-utils.d.ts
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>;
20 changes: 20 additions & 0 deletions test-app/tests/unit/utils/transition-utils-test.ts
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');
});
});

0 comments on commit 0852867

Please sign in to comment.