Skip to content

Commit 5068ad9

Browse files
authored
fix: the "nearest" position is working properly (#207)
* add another w3c test * fixes and tweaks * attempting to make the new tests pass * fix them tests * fixing more edge cases * refactor for clarity * testing if logic for block and inline can be reused * small typo * maybe we can * yes we can * cleanup * allow boundary to be a callback * add bundlesize checks * fix readme example
1 parent f18c114 commit 5068ad9

File tree

9 files changed

+233
-153
lines changed

9 files changed

+233
-153
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
- restore-cache: *restore-cache
4040
- *install
4141
- run: yarn build
42+
- run: npx bundlesize
4243
- save-cache: *save-cache
4344

4445
Web Platform Tests:

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ node_modules
44
**/cypress/screenshots
55
**/cypress/videos
66

7+
# Typescript stuff
8+
typings
9+
src/*.js
10+
711
lerna-debug.log
812
.next
913
dist
1014
es
11-
typings
1215
umd
1316
/compute.js
1417
/index.js

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ scrollIntoView(node, {
6262
// Your scroll actions will always be an array, even if there is nothing to scroll
6363
behavior: scrollActions =>
6464
// list is sorted from innermost (closest parent to your target) to outermost (often the document.body or viewport)
65-
scrollActions.forEach(([el, scrollTop, scrollLeft]) => {
65+
scrollActions.forEach(({ el, top, left }) => {
6666
// implement the scroll anyway you want
67-
el.scrollTop = scrollTop
68-
el.scrollLeft = scrollLeft
67+
el.scrollTop = top
68+
el.scrollLeft = left
6969

70-
// If you need the relative scroll coordinates, for things like window.scrollBy style logic, just do the math
71-
const offsetTop = el.scrollTop - scrollTop
72-
const offsetLeft = el.scrollLeft - scrollLeft
70+
// If you need the relative scroll coordinates, for things like window.scrollBy style logic or whatever, just do the math
71+
const offsetTop = el.scrollTop - top
72+
const offsetLeft = el.scrollLeft - left
7373
}),
7474
// all the other options (scrollMode, block, inline) still work, so you don't need to reimplement them (unless you really really want to)
7575
})

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@
8181
"loose-envify"
8282
]
8383
},
84+
"bundlesize": [
85+
{
86+
"path": "./umd/scroll-into-view-if-needed.min.js",
87+
"maxSize": "1.5 kB"
88+
},
89+
{
90+
"path": "./umd/scroll-into-view-if-needed.js",
91+
"maxSize": "2.3 kB"
92+
}
93+
],
8494
"lint-staged": {
8595
"*.js": [
8696
"prettier --write",

0 commit comments

Comments
 (0)