Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 7d0394b

Browse files
pgbrosstraviskaufman
pgbross
authored andcommitted
feat(menu): Export util (#824)
Resolves #823
1 parent 307305c commit 7d0394b

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

packages/mdc-menu/README.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ console.log(`Menu is ${menu.open ? 'open' : 'closed'}.`);
195195
##### ES2015
196196

197197
```javascript
198-
import {MDCSimpleMenu, MDCSimpleMenuFoundation} from 'mdc-menu';
198+
import {MDCSimpleMenu, MDCSimpleMenuFoundation, util} from 'mdc-menu';
199199
```
200200

201201
##### CommonJS
@@ -204,6 +204,7 @@ import {MDCSimpleMenu, MDCSimpleMenuFoundation} from 'mdc-menu';
204204
const mdcMenu = require('mdc-menu');
205205
const MDCSimpleMenu = mdcMenu.MDCSimpleMenu;
206206
const MDCSimpleMenuFoundation = mdcMenu.MDCSimpleMenuFoundation;
207+
const util = mdcMenu.util;
207208
```
208209

209210
##### AMD
@@ -212,6 +213,7 @@ const MDCSimpleMenuFoundation = mdcMenu.MDCSimpleMenuFoundation;
212213
require(['path/to/mdc-menu'], mdcMenu => {
213214
const MDCSimpleMenu = mdcMenu.MDCSimpleMenu;
214215
const MDCSimpleMenuFoundation = mdcMenu.MDCSimpleMenuFoundation;
216+
const util = mdcMenu.util;
215217
});
216218
```
217219

@@ -220,6 +222,7 @@ require(['path/to/mdc-menu'], mdcMenu => {
220222
```javascript
221223
const MDCSimpleMenu = mdc.Menu.MDCSimpleMenu;
222224
const MDCSimpleMenuFoundation = mdc.Menu.MDCSimpleMenuFoundation;
225+
const util = mdc.menu.util;
223226
```
224227

225228
#### Automatic Instantiation
@@ -306,3 +309,29 @@ Closes the menu.
306309
#### MDCSimpleMenuFoundation.isOpen() => boolean
307310

308311
Returns whether or not the menu is open.
312+
313+
314+
### The util API
315+
External frameworks and libraries can use the following utility methods when integrating a component.
316+
317+
#### util.getTransformPropertyName(globalObj, forceRefresh = false) => String
318+
319+
Returns the name of the correct transform property to use on the current browser.
320+
321+
#### util.clamp(value, min = 0, max = 1) => Number
322+
323+
Clamps a value between the minimum and the maximum, returning the clamped value.
324+
325+
#### util.bezierProgress(time, x1, y1, x2, y2) => Number
326+
327+
Returns the easing value to apply at time t, for a given cubic bezier curve.
328+
329+
```
330+
Control points P0 and P3 are assumed to be (0,0) and (1,1), respectively.
331+
Parameters are as follows:
332+
- time: The current time in the animation, scaled between 0 and 1.
333+
- x1: The x value of control point P1.
334+
- y1: The y value of control point P1.
335+
- x2: The x value of control point P2.
336+
- y2: The y value of control point P2.
337+
```

packages/mdc-menu/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17+
import * as util from './util';
1718
export {MDCSimpleMenu, MDCSimpleMenuFoundation} from './simple';
19+
export {util};

0 commit comments

Comments
 (0)