Skip to content

Commit e9e61d1

Browse files
committed
v2.2.0 release
1 parent 374f3cd commit e9e61d1

8 files changed

+5315
-435
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ root = true
33
[*]
44
charset = utf-8
55
indent_style = space
6-
indent_size = 2
6+
indent_size = 4
77
end_of_line = lf
88
insert_final_newline = true
99
trim_trailing_whitespace = true

.prettierrc.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
singleQuote: true,
3+
trailingComma: 'es5',
4+
arrowParens: 'always',
5+
printWidth: 120,
6+
tabWidth: 4,
7+
};

README.md

+8-14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Enjoyable drag-to-scroll micro library (~2KB gzipped). Supports smooth content scroll via mouse/touch dragging, trackpad or mouse wheel. Zero dependencies.
44

5+
Easy to setup yet flexible enough to support any custom scrolling logic.
6+
57
### Installation
68

79
You can install it via `npm` or `yarn` package manager or via `script` tag:
@@ -15,7 +17,7 @@ yarn add scrollbooster
1517
```
1618

1719
``` html
18-
<script src="https://unpkg.com/scrollbooster@2.0.0/dist/scrollbooster.min.js"></script>
20+
<script src="https://unpkg.com/scrollbooster@2/dist/scrollbooster.min.js"></script>
1921
```
2022

2123
### Usage
@@ -25,19 +27,9 @@ The most simple setup with default settings:
2527
``` js
2628
import ScrollBooster from 'scrollbooster';
2729

28-
const viewport = document.querySelector('.viewport');
29-
const content = document.querySelector('.scrollable-content');
30-
3130
new ScrollBooster({
32-
viewport,
33-
content,
34-
onUpdate: (state) => {
35-
content.style.transform = `translate(
36-
${-state.position.x}px,
37-
${-state.position.y}px
38-
)`;
39-
},
40-
// other options (see below)
31+
viewport: document.querySelector('.viewport'),
32+
scrollMode: 'transform'
4133
});
4234
```
4335

@@ -49,6 +41,7 @@ Option | Type | Default | Description
4941
------ | ---- | ------- | -----------
5042
viewport | DOM Node | null | Content viewport element (required)
5143
content | DOM Node | viewport child element | Scrollable content element inside viewport
44+
scrollMode | String | undefined | Scroll technique - via CSS transform or natively. Could be 'transform' or 'native'
5245
direction | String | 'all' | Scroll direction. Could be 'horizontal', 'vertical' or 'all'
5346
bounce | Boolean | true | Enables elastic bounce effect when hitting viewport borders
5447
textSelection | Boolean | false | Enables text selection inside viewport
@@ -86,6 +79,7 @@ const sb = new ScrollBooster({
8679
emulateScroll: true,
8780
onUpdate: (state) => {
8881
// state contains useful metrics: position, dragOffset, isDragging, isMoving, borderCollision
82+
// you can control scroll rendering manually without 'scrollMethod' option:
8983
content.style.transform = `translate(
9084
${-state.position.x}px,
9185
${-state.position.y}px
@@ -107,7 +101,7 @@ const sb = new ScrollBooster({
107101

108102
// methods usage examples:
109103
sb.updateMetrics();
110-
sb.setPosition({ x: 100, y: 100 });
104+
sb.scrollTo({ x: 100, y: 100 });
111105
sb.updateOptions({ emulateScroll: false });
112106
sb.destroy();
113107
```

dist/scrollbooster.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/scrollbooster.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "scrollbooster",
33
"description": "Enjoyable content drag-to-scroll library",
4-
"version": "2.1.0",
4+
"version": "2.2.0",
55
"author": "Ilya Shubin <[email protected]>",
66
"license": "MIT",
77
"main": "dist/scrollbooster.min.js",
@@ -11,7 +11,10 @@
1111
"build": "webpack --mode production",
1212
"start": "webpack-dev-server --host 0.0.0.0"
1313
},
14-
"browserslist": ["> 0.25%", "not dead"],
14+
"browserslist": [
15+
"> 0.25%",
16+
"not dead"
17+
],
1518
"repository": {
1619
"type": "git",
1720
"url": "git+https://github.com/ilyashubin/scrollbooster.git"

0 commit comments

Comments
 (0)