Skip to content
This repository was archived by the owner on Feb 11, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .babelrc.js
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,4 @@ module.exports = {
es6: true,
mocha: true,
},
globals: {
YT: true,
},
};
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
/node_modules
*.log
.coverage
.rpt2_cache
.rpt2_cache
dist
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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>
Loading