Skip to content

Commit 8aab623

Browse files
committed
fix linting errors
1 parent b22d31a commit 8aab623

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

src/easing.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
const easeInOutQuad = (t, b, c, d) => {
77
t /= d / 2
8-
if(t < 1) return c / 2 * t * t + b
8+
if (t < 1) return c / 2 * t * t + b
99
t--
1010
return -c / 2 * (t * (t - 2) - 1) + b
1111
}

src/jump.js

+25-25
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ const jumper = () => {
2525

2626
// scroll position helper
2727

28-
function location() {
28+
function location () {
2929
return window.scrollY || window.pageYOffset
3030
}
3131

3232
// element offset helper
3333

34-
function top(element) {
34+
function top (element) {
3535
return element.getBoundingClientRect().top + start
3636
}
3737

3838
// rAF loop helper
3939

40-
function loop(timeCurrent) {
40+
function loop (timeCurrent) {
4141
// store time scroll started, if not started already
42-
if(!timeStart) {
42+
if (!timeStart) {
4343
timeStart = timeCurrent
4444
}
4545

@@ -54,18 +54,18 @@ const jumper = () => {
5454

5555
// check progress
5656
timeElapsed < duration
57-
? requestAnimationFrame(loop) // continue scroll loop
58-
: done() // scrolling is done
57+
? window.requestAnimationFrame(loop) // continue scroll loop
58+
: done() // scrolling is done
5959
}
6060

6161
// scroll finished helper
6262

63-
function done() {
63+
function done () {
6464
// account for rAF time rounding inaccuracies
6565
window.scrollTo(0, start + distance)
6666

6767
// if scrolling to an element, and accessibility is enabled
68-
if(element && a11y) {
68+
if (element && a11y) {
6969
// add tabindex indicating programmatic focus
7070
element.setAttribute('tabindex', '-1')
7171

@@ -74,7 +74,7 @@ const jumper = () => {
7474
}
7575

7676
// if it exists, fire the callback
77-
if(typeof callback === 'function') {
77+
if (typeof callback === 'function') {
7878
callback()
7979
}
8080

@@ -84,59 +84,59 @@ const jumper = () => {
8484

8585
// API
8686

87-
function jump(target, options = {}) {
87+
function jump (target, options = {}) {
8888
// resolve options, or use defaults
8989
duration = options.duration || 1000
90-
offset = options.offset || 0
90+
offset = options.offset || 0
9191
callback = options.callback // "undefined" is a suitable default, and won't be called
92-
easing = options.easing || easeInOutQuad
93-
a11y = options.a11y || false
92+
easing = options.easing || easeInOutQuad
93+
a11y = options.a11y || false
9494

9595
// cache starting position
9696
start = location()
9797

9898
// resolve target
99-
switch(typeof target) {
99+
switch (typeof target) {
100100
// scroll from current position
101101
case 'number':
102102
element = undefined // no element to scroll to
103-
a11y = false // make sure accessibility is off
104-
stop = start + target
105-
break
103+
a11y = false // make sure accessibility is off
104+
stop = start + target
105+
break
106106

107107
// scroll to element (node)
108108
// bounding rect is relative to the viewport
109109
case 'object':
110110
element = target
111-
stop = top(element)
112-
break
111+
stop = top(element)
112+
break
113113

114114
// scroll to element (selector)
115115
// bounding rect is relative to the viewport
116116
case 'string':
117117
element = document.querySelector(target)
118-
stop = top(element)
119-
break
118+
stop = top(element)
119+
break
120120
}
121121

122122
// resolve scroll distance, accounting for offset
123123
distance = stop - start + offset
124124

125125
// resolve duration
126-
switch(typeof options.duration) {
126+
switch (typeof options.duration) {
127127
// number in ms
128128
case 'number':
129129
duration = options.duration
130-
break
130+
break
131131

132132
// function passed the distance of the scroll
133133
case 'function':
134134
duration = options.duration(distance)
135-
break
135+
break
136136
}
137137

138138
// start the loop
139-
requestAnimationFrame(loop)
139+
window.requestAnimationFrame(loop)
140140
}
141141

142142
// expose only the jump method

0 commit comments

Comments
 (0)