Skip to content

Commit

Permalink
feat(drawer): Export util methods (#423)
Browse files Browse the repository at this point in the history
Resolves #422
  • Loading branch information
pgbross authored and traviskaufman committed Mar 29, 2017
1 parent 888be2c commit 1babd7c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 31 additions & 1 deletion packages/mdc-drawer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ correct drawer behaviors into idiomatic components.
##### ES2015

```javascript
import {MDCTemporaryDrawer, MDCTemporaryDrawerFoundation} from 'mdc-drawer';
import {MDCTemporaryDrawer, MDCTemporaryDrawerFoundation, util} from 'mdc-drawer';
```

##### CommonJS
Expand All @@ -183,6 +183,7 @@ import {MDCTemporaryDrawer, MDCTemporaryDrawerFoundation} from 'mdc-drawer';
const mdcDrawer = require('mdc-drawer');
const MDCTemporaryDrawer = mdcDrawer.MDCTemporaryDrawer;
const MDCTemporaryDrawerFoundation = mdcDrawer.MDCTemporaryDrawerFoundation;
const util = mdcDrawer.util;
```

##### AMD
Expand All @@ -191,6 +192,7 @@ const MDCTemporaryDrawerFoundation = mdcDrawer.MDCTemporaryDrawerFoundation;
require(['path/to/mdc-drawer'], mdcDrawer => {
const MDCTemporaryDrawer = mdcDrawer.MDCTemporaryDrawer;
const MDCTemporaryDrawerFoundation = mdcDrawer.MDCTemporaryDrawerFoundation;
const util = mdcDrawer.util;
});
```

Expand All @@ -199,6 +201,7 @@ require(['path/to/mdc-drawer'], mdcDrawer => {
```javascript
const MDCTemporaryDrawer = mdc.drawer.MDCTemporaryDrawer;
const MDCTemporaryDrawerFoundation = mdc.drawer.MDCTemporaryDrawerFoundation;
const util = mdc.drawer.util;
```

#### Automatic Instantiation
Expand Down Expand Up @@ -249,3 +252,30 @@ The adapter for temporary drawers must provide the following functions, with cor
| `makeElementUntabbable(el: Element) => void` | Makes an element untabbable. |
| `isRtl() => boolean` | Returns boolean indicating whether the current environment is RTL. |
| `isDrawer(el: Element) => boolean` | Returns boolean indicating whether the provided element is the drawer container sub-element. |

### The util API
External frameworks and libraries can use the following utility methods when integrating a component.

#### util.remapEvent(eventName, globalObj = window) => String

Remap touch events to pointer events, if the browser doesn't support touch events.

#### util.getTransformPropertyName(globalObj = window, forceRefresh = false) => String

Choose the correct transform property to use on the current browser.

#### util.supportsCssCustomProperties(globalObj = window) => Boolean

Determine whether the current browser supports CSS properties.

#### util.applyPassive(globalObj = window, forceRefresh = false) => object

Determine whether the current browser supports passive event listeners, and if so, use them.

#### util.saveElementTabState(el) => void

Save the tab state for an element.

#### util.restoreElementTabState(el) => void

Restore the tab state for an element, if it was saved.
2 changes: 2 additions & 0 deletions packages/mdc-drawer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
* limitations under the License.
*/

import * as util from './util';
export {MDCTemporaryDrawer, MDCTemporaryDrawerFoundation} from './temporary';
export {util};

0 comments on commit 1babd7c

Please sign in to comment.