Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
ESM and CommonJS updates (#43)
Browse files Browse the repository at this point in the history
* Add ESM module entry point to package
* Move `main` to `module` in package.json
* Generate commonjs output and set to `main`
* Sync package.json and package-lock.json
* Remove dead eslint global
* Remove rollup-plugin-node-resolve
* Output ESM file properly
* Use babel to support IE11
* Ignore dist folder during dev
* * Use `rollup-plugin-serve`
* Consolidate rollup watch and static server into `npm start`
* Update README to use `npm start`
* Add index.html file to support navigating to /examples using static server
  • Loading branch information
Mark Kennedy committed Aug 18, 2019
1 parent d655275 commit fe00cc3
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 283 deletions.
14 changes: 13 additions & 1 deletion .babelrc.js
@@ -1,3 +1,15 @@
module.exports = {
presets: ['@babel/preset-typescript'],
presets: [
'@babel/preset-typescript',
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
corejs: 3,
targets: {
browsers: ['last 2 versions', 'ie >= 11'],
},
},
],
],
};
3 changes: 0 additions & 3 deletions .eslintrc.js
Expand Up @@ -11,7 +11,4 @@ module.exports = {
es6: true,
mocha: true,
},
globals: {
YT: true,
},
};
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -7,4 +7,5 @@
/node_modules
*.log
.coverage
.rpt2_cache
.rpt2_cache
dist
22 changes: 11 additions & 11 deletions README.md
Expand Up @@ -145,26 +145,26 @@ The `scrollTo` method allows a set of options which are synonymous with the
[ScrollToOptions](https://drafts.csswg.org/cssom-view/#dictdef-scrolltooptions) of the CSS specification,
but some additional ones are provided by this library until supported natively.

| Option | Type | Description |
| ---------- | ------ | ----------- |
| `behavior` | String | The type of [scroll behavior](https://drafts.csswg.org/cssom-view/#enumdef-scrollbehavior) which can be set to `auto` or `smooth`. This is the recommended option since this is already natively supported. **If this is set, all other options are ignored**. |
| Option | Type | Description |
| ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `behavior` | String | The type of [scroll behavior](https://drafts.csswg.org/cssom-view/#enumdef-scrollbehavior) which can be set to `auto` or `smooth`. This is the recommended option since this is already natively supported. **If this is set, all other options are ignored**. |
| `duration` | Number | The number of milliseconds the scroll will take to complete |
| `easing` | String | The easing to use when scrolling. Only keyword values of the [animation-timing-function](https://drafts.csswg.org/css-animations/#animation-timing-function) are supported. But passing function values will eventually be supported also (ie. `cubic-bezier(0.1, 0.7, 1.0, 0.1)`, `steps(4, end)`, etc) |

### scrollIntoView(element, [scroller], [options])

| Option | Type | Description |
| ---------- | ----------------------- | ---------------------------- |
| `element` | `HTMLElement` | The element to scroll into the viewport |
| `scroller` | `HTMLElement` | The element to be scrolled (defaults to `document.body`) |
| `options` | `ScrollIntoViewOptions` | A set of scroll options to scroll the element into view (see writeup below) (i.e. `{behavior: 'smooth', top: '20', left: '0''}`) |
| Option | Type | Description |
| ---------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `element` | `HTMLElement` | The element to scroll into the viewport |
| `scroller` | `HTMLElement` | The element to be scrolled (defaults to `document.body`) |
| `options` | `ScrollIntoViewOptions` | A set of scroll options to scroll the element into view (see writeup below) (i.e. `{behavior: 'smooth', top: '20', left: '0''}`) |

#### scrollIntoView Options

A set of [ScrollIntoViewOptions](https://drafts.csswg.org/cssom-view/#dictdef-scrollintoviewoptions) can be passed to the `scrollIntoView` method.

| Option | Type | Description |
| ---------- | ------ | ---------------------------------------------------------------------------------------------------- |
| Option | Type | Description |
| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `behavior` | String | The type of [scroll behavior](https://drafts.csswg.org/cssom-view/#enumdef-scrollbehavior) which can be set to `auto` or `smooth`. Defaults to `auto`. |

## Examples
Expand All @@ -173,7 +173,7 @@ Code samples showing how to use this package can be found in the [examples](exam
and

```bash
npm run start-server
npm start
```

Which will make the examples available at http://localhost:9383/examples/.
Expand Down
19 changes: 0 additions & 19 deletions dist/scroll.d.ts

This file was deleted.

184 changes: 0 additions & 184 deletions dist/scroll.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/scroll.min.js

This file was deleted.

14 changes: 14 additions & 0 deletions examples/index.html
@@ -0,0 +1,14 @@
<html lang="en-us">
<head>
<title>Examples</title>
</head>

<body>
<ul>
<li>
<a href="scroll-to-element.html">scroll-to-element.html</a>
</li>
<li><a href="vertical-scroll.html">vertical-scroll.html</a></li>
</ul>
</body>
</html>

0 comments on commit fe00cc3

Please sign in to comment.