Skip to content

Commit 7c52462

Browse files
authored
fix: safari (#14)
1 parent b11f147 commit 7c52462

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/index.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function smoothScroll(el, x, y, cb) {
4949
var startTime = now()
5050

5151
// define scroll context
52-
if (el === document.body || (el === document.documentElement && true)) {
52+
if (el === document.documentElement) {
5353
scrollable = window
5454
startX = window.scrollX || window.pageXOffset
5555
startY = window.scrollY || window.pageYOffset
@@ -79,7 +79,6 @@ function smoothScroll(el, x, y, cb) {
7979

8080
export default (target, options: Options = {}) => {
8181
const { behavior = 'smooth' } = options
82-
//return target.scrollIntoView(options)
8382

8483
// @TODO detect if someone is using this library without smooth behavior and maybe warn
8584
if (behavior !== 'smooth') {
@@ -88,14 +87,12 @@ export default (target, options: Options = {}) => {
8887

8988
return scrollIntoView(target, {
9089
...options,
91-
behavior: instructions => {
92-
return Promise.all(
93-
instructions.map(({ el, left, top }) => {
94-
return new Promise(resolve => {
95-
smoothScroll(el, left, top, () => resolve())
96-
})
97-
})
98-
)
99-
},
90+
behavior: actions =>
91+
Promise.all(
92+
actions.map(
93+
({ el, left, top }) =>
94+
new Promise(resolve => smoothScroll(el, left, top, () => resolve()))
95+
)
96+
),
10097
})
10198
}

0 commit comments

Comments
 (0)