You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+19-21
Original file line number
Diff line number
Diff line change
@@ -37,10 +37,10 @@ import jump from 'jump.js'
37
37
38
38
### Call
39
39
40
-
Jump exports a _singleton_, so there's no need to create an instance. Just call it, passing in a [target](#target).
40
+
Jump exports a _singleton_, so there's no need to create an instance. Just call it, passing a [target](#target).
41
41
42
42
```es6
43
-
// call Jump
43
+
// call Jump, passing a target
44
44
45
45
jump('.target')
46
46
```
@@ -49,11 +49,9 @@ Note that the singleton can make an infinite number of jumps.
49
49
50
50
## Options
51
51
52
-
All options, **except [target](#target)**, are optional, and have sensible defaults. Default options are shown below.
52
+
All options, **except [target](#target)**, are optional, and have sensible defaults. The defaults are shown below:
53
53
54
54
```es6
55
-
// default options
56
-
57
55
jump('.target', {
58
56
duration:1000,
59
57
offset:0,
@@ -86,19 +84,22 @@ jump(100)
86
84
jump(-100)
87
85
```
88
86
89
-
Or, scroll _to an element_ by passing a node or a selector.
87
+
Or, scroll _to an element_, by passing either:
88
+
89
+
* a node, or
90
+
* a CSS selector
90
91
91
92
```es6
92
93
// passing a node
93
94
94
-
constnode=document.querySelector('#target')
95
+
constnode=document.querySelector('.target')
95
96
96
97
jump(node)
97
98
98
-
// passing a selector
99
-
// the element is resolved using document.querySelector
99
+
// passing a CSS selector
100
+
// the element referenced by the selector is determined using document.querySelector
100
101
101
-
jump('#target')
102
+
jump('.target')
102
103
```
103
104
104
105
### duration
@@ -111,7 +112,7 @@ jump('.target', {
111
112
})
112
113
```
113
114
114
-
Or, pass a function accepting `distance` (in `px`) as an argument, that returns the duration of the `jump()`, in milliseconds.
115
+
Or, pass a function that returns the duration of the `jump()` in milliseconds. This function is passed the `jump()``distance`, in `px`, as a parameter.
115
116
116
117
```es6
117
118
jump('.target', {
@@ -137,24 +138,18 @@ jump('.target', {
137
138
})
138
139
```
139
140
140
-
Note that this option is useful for accommodating elements `position: fixed`to the top/bottom of the screen.
141
+
Note that this option is useful for accommodating `position: fixed`elements.
141
142
142
143
### callback
143
144
144
-
Pass a function to be called after the `jump()` has been completed.
145
+
Pass a function that will be called after the `jump()` has been completed.
145
146
146
147
```es6
147
-
// in both regular and arrow functions, 'this' === 'window'
148
+
// in both regular and arrow functions, this === window
148
149
149
150
jump('.target', {
150
151
callback: () =>console.log('Jump completed!')
151
152
})
152
-
153
-
jump('.target', {
154
-
callback:function() {
155
-
console.log('Jump completed!')
156
-
}
157
-
})
158
153
```
159
154
160
155
### easing
@@ -171,7 +166,10 @@ See [easing.js](https://github.com/callmecavs/jump.js/blob/master/src/easing.js)
171
166
172
167
### a11y
173
168
174
-
If enabled, _and scrolling to an element_, add a [`tabindex`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex) to, and [`focus`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus), the element.
169
+
If enabled, _and scrolling to an element_:
170
+
171
+
* add a [`tabindex`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex) to, and
172
+
*[`focus`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) the element
0 commit comments