Skip to content

Commit 78973d3

Browse files
authored
Changelog: 🚀
### Added * New `handleScroll` option allows customizing scrolling behavior. ### Changed * Animation logic is separated from scroll calculation logic. This allows skip importing animation dependencies and reduces bundle sizes when you don't need the built in animation feature. ### What this means Take control over how the target is scrolled into view. This function is called for each parent node that need scrolling. `scrollLeft` and `scrollTop` are destination coordinates. The from coordinates you'll have to get yourself if you want to animate the transition using a different library. When using this option you likely don't need the built in animation feature. To cut down on filesize you can do the following adjustment if you are using a recent version of webpack or rollbar (and use ES6 imports): ```diff -import scrollIntoViewIfNeeded from 'scroll-into-view-if-needed' +import maybeScrollIntoView from 'scroll-into-view-if-needed/dist/calculate' -scrollIntoViewIfNeeded(node) +maybeScrollIntoView(node, {handleScroll: (parent, {scrollLeft, scrollTop}, config) => { + // The following is actually the default implementation + // if this is all you need you can skip passing this option + parent.scrollLeft = scrollLeft + parent.scrollTop = scrollTop +}}) ```
1 parent b24197e commit 78973d3

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
cypress
44
docs
55
example
6+
junit
67
src
78
.editorconfig
89
.prettierignore

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Change the easing mechanism. This option takes effect when `duration` is set. In
8181

8282
> Introduced in `v1.4.0`
8383
84-
Type: `function`
84+
Type: `Function`
8585

8686
Take control over how the target is scrolled into view. This function is called
8787
for each parent node that need scrolling. `scrollLeft` and `scrollTop` are

0 commit comments

Comments
 (0)