Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pointerMode | String | 'all' | Specify pointer type. Supported values - 'touch'
friction | Number | 0.05 | Scroll friction factor - how fast scrolling stops after pointer release
bounceForce | Number | 0.1 | Elastic bounce effect factor
emulateScroll | Boolean | false | Enables mouse wheel/trackpad emulation inside viewport
rtl | Boolean | false | Enables right-to-left scroll behavior
preventDefaultOnEmulateScroll | String | false | Prevents horizontal or vertical default when `emulateScroll` is enabled (eg. useful to prevent horizontal trackpad gestures while enabling vertical scrolling). Could be 'horizontal' or 'vertical'.
lockScrollOnDragDirection | String | false | Detect drag direction and either prevent default `mousedown`/`touchstart` event or lock content scroll. Could be 'horizontal', 'vertical' or 'all'
dragDirectionTolerance | Number | 40 | Tolerance for horizontal or vertical drag detection
Expand Down
13 changes: 11 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default class ScrollBooster {
* @param {Boolean} options.textSelection - enables text selection
* @param {Boolean} options.inputsFocus - enables focus on input elements
* @param {Boolean} options.emulateScroll - enables mousewheel emulation
* @param {Boolean} options.rtl - enables right-to-left direction for scroll
* @param {Function} options.onClick - click handler
* @param {Function} options.onUpdate - state update handler
* @param {Function} options.onWheel - wheel handler
Expand All @@ -64,6 +65,7 @@ export default class ScrollBooster {
textSelection: false,
inputsFocus: true,
emulateScroll: false,
rtl: false,
preventDefaultOnEmulateScroll: false, // 'vertical', 'horizontal'
preventPointerMoveDefault: true,
lockScrollOnDragDirection: false, // 'vertical', 'horizontal', 'all'
Expand Down Expand Up @@ -136,10 +138,17 @@ export default class ScrollBooster {
width: getFullWidth(this.props.content),
height: getFullHeight(this.props.content),
};
this.edgeX = {
if (this.props.rtl) {
this.edgeX = {
from: 0,
to: Math.max(this.content.width - this.viewport.width, 0),
};
} else {
this.edgeX = {
from: Math.min(-this.content.width + this.viewport.width, 0),
to: 0,
};
};
}
this.edgeY = {
from: Math.min(-this.content.height + this.viewport.height, 0),
to: 0,
Expand Down