Skip to content

Commit 405a1e8

Browse files
jgmcelwainrigor789
authored andcommitted
Add element parameter to onStart and onDone callbacks (rigor789#79)
* Add element parameter to onStart and onDone callbacks * Add element param to onCancel callback
1 parent 178faea commit 405a1e8

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ var options = {
136136
easing: 'ease-in',
137137
offset: -60,
138138
cancelable: true,
139-
onStart: function() {
139+
onStart: function(element) {
140140
// scrolling started
141141
},
142-
onDone: function() {
142+
onDone: function(element) {
143143
// scrolling is done
144144
},
145145
onCancel: function() {
@@ -189,17 +189,17 @@ Indicates if user can cancel the scroll or not.
189189
*Default:* `true`
190190

191191
#### onStart
192-
A callback function that should be called when scrolling has started.
192+
A callback function that should be called when scrolling has started. Receives the target element as a parameter.
193193

194194
*Default:* `noop`
195195

196196
#### onDone
197-
A callback function that should be called when scrolling has ended.
197+
A callback function that should be called when scrolling has ended. Receives the target element as a parameter.
198198

199199
*Default:* `noop`
200200

201201
#### onCancel
202-
A callback function that should be called when scrolling has been aborted by the user (user scrolled, clicked etc.).
202+
A callback function that should be called when scrolling has been aborted by the user (user scrolled, clicked etc.). Receives the abort event and the target element as parameters.
203203

204204
*Default:* `noop`
205205

src/scrollTo.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ export const scroller = () => {
112112
timeStart = false;
113113

114114
_.off(container, abortEvents, abortFn);
115-
if (abort && onCancel) onCancel(abortEv);
116-
if (!abort && onDone) onDone();
115+
if (abort && onCancel) onCancel(abortEv, element);
116+
if (!abort && onDone) onDone(element);
117117
}
118118

119119
function topLeft(element, top, left) {
@@ -186,7 +186,7 @@ export const scroller = () => {
186186
easingFn = BezierEasing.apply(BezierEasing, easing);
187187

188188
if (!diffY && !diffX) return;
189-
if (onStart) onStart();
189+
if (onStart) onStart(element);
190190

191191
_.on(container, abortEvents, abortFn, { passive: true });
192192

vue-scrollto.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ var scroller = function scroller() {
309309
timeStart = false;
310310

311311
_.off(container, abortEvents, abortFn);
312-
if (abort && onCancel) onCancel(abortEv);
313-
if (!abort && onDone) onDone();
312+
if (abort && onCancel) onCancel(abortEv, element);
313+
if (!abort && onDone) onDone(element);
314314
}
315315

316316
function topLeft(element, top, left) {
@@ -376,7 +376,7 @@ var scroller = function scroller() {
376376
easingFn = src.apply(src, easing);
377377

378378
if (!diffY && !diffX) return;
379-
if (onStart) onStart();
379+
if (onStart) onStart(element);
380380

381381
_.on(container, abortEvents, abortFn, { passive: true });
382382

0 commit comments

Comments
 (0)