Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add post reset function #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ There are a few optional parameters you can pass on initialization:
// Number of pixels of dragging down until refresh will fire
distanceToRefresh: 70,

// The dragging resistance level, the higher the more you'll need to drag down.
resistance: 2.5
// The dragging resistance level, the higher the more you'll need to drag down.
resistance: 2.5,

// Pointer to function that will be called post reset
postResetFunction: function() { }
}
```

Expand Down
13 changes: 11 additions & 2 deletions lib/wptr.1.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ var WebPullToRefresh = (function () {
loadingFunction: false,

// Dragging resistance level
resistance: 2.5
resistance: 2.5,

// Pointer to function that will be called post reset
postResetFunction: false
};

/**
Expand Down Expand Up @@ -55,7 +58,8 @@ var WebPullToRefresh = (function () {
ptrEl: params.ptrEl || document.getElementById( defaults.ptrEl ),
distanceToRefresh: params.distanceToRefresh || defaults.distanceToRefresh,
loadingFunction: params.loadingFunction || defaults.loadingFunction,
resistance: params.resistance || defaults.resistance
resistance: params.resistance || defaults.resistance,
postResetFunction: params.postResetFunction || defaults.postResetFunction
};

if ( ! options.contentEl || ! options.ptrEl ) {
Expand Down Expand Up @@ -204,6 +208,11 @@ var WebPullToRefresh = (function () {
};

document.body.addEventListener( 'transitionend', bodyClassRemove, false );

// If a post reset function has been defined, call it
if ( typeof(options.postResetFunction) === typeof(Function) ) {
options.postResetFunction();
}
};

return {
Expand Down