Skip to content
This repository has been archived by the owner on Jan 24, 2018. It is now read-only.

Added afterFling listener #653

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/skrollr.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@
render: options.render,

//Function to be called whenever an element with the `data-emit-events` attribute passes a keyframe.
keyframe: options.keyframe
keyframe: options.keyframe,

//Function to be called after a fling animation has ended
afterfling: options.afterfling
};

//forceHeight is true by default
Expand Down Expand Up @@ -807,7 +810,8 @@

duration = duration * (1 - targetRatio);

_instance.animateTo((targetTop + 0.5) | 0, {easing: 'outCubic', duration: duration});
var direction = (distanceY)>0?'down':'up';
_instance.animateTo((targetTop + 0.5) | 0, {easing: 'outCubic', duration: duration, done: _listeners.afterfling(direction)});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code doesn't work, you're executing _listeners.afterfling(direction) immediately.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh, you're right!

break;
}
});
Expand Down