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

Commit fe00cc3

Browse files
author
Mark Kennedy
authored
ESM and CommonJS updates (#43)
* 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
1 parent d655275 commit fe00cc3

File tree

12 files changed

+112
-283
lines changed

12 files changed

+112
-283
lines changed

.babelrc.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
module.exports = {
2-
presets: ['@babel/preset-typescript'],
2+
presets: [
3+
'@babel/preset-typescript',
4+
[
5+
'@babel/preset-env',
6+
{
7+
useBuiltIns: 'usage',
8+
corejs: 3,
9+
targets: {
10+
browsers: ['last 2 versions', 'ie >= 11'],
11+
},
12+
},
13+
],
14+
],
315
};

.eslintrc.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,4 @@ module.exports = {
1111
es6: true,
1212
mocha: true,
1313
},
14-
globals: {
15-
YT: true,
16-
},
1714
};

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
/node_modules
88
*.log
99
.coverage
10-
.rpt2_cache
10+
.rpt2_cache
11+
dist

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,26 +145,26 @@ The `scrollTo` method allows a set of options which are synonymous with the
145145
[ScrollToOptions](https://drafts.csswg.org/cssom-view/#dictdef-scrolltooptions) of the CSS specification,
146146
but some additional ones are provided by this library until supported natively.
147147

148-
| Option | Type | Description |
149-
| ---------- | ------ | ----------- |
150-
| `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**. |
148+
| Option | Type | Description |
149+
| ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
150+
| `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**. |
151151
| `duration` | Number | The number of milliseconds the scroll will take to complete |
152152
| `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) |
153153

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

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

162162
#### scrollIntoView Options
163163

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

166-
| Option | Type | Description |
167-
| ---------- | ------ | ---------------------------------------------------------------------------------------------------- |
166+
| Option | Type | Description |
167+
| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
168168
| `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`. |
169169

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

175175
```bash
176-
npm run start-server
176+
npm start
177177
```
178178

179179
Which will make the examples available at http://localhost:9383/examples/.

dist/scroll.d.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

dist/scroll.js

Lines changed: 0 additions & 184 deletions
This file was deleted.

dist/scroll.min.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<html lang="en-us">
2+
<head>
3+
<title>Examples</title>
4+
</head>
5+
6+
<body>
7+
<ul>
8+
<li>
9+
<a href="scroll-to-element.html">scroll-to-element.html</a>
10+
</li>
11+
<li><a href="vertical-scroll.html">vertical-scroll.html</a></li>
12+
</ul>
13+
</body>
14+
</html>

0 commit comments

Comments
 (0)