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

Get elements for IDs passed as contentEl and ptrEl options. Fixes #11. #12

Open
wants to merge 1 commit 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
32 changes: 16 additions & 16 deletions lib/wptr.1.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ var WebPullToRefresh = (function () {
/**
* Hold all of the default parameters for the module
* @type {object}
*/
*/
var defaults = {
// ID of the element holding pannable content area
contentEl: 'content',
contentEl: 'content',

// ID of the element holding pull to refresh loading area
ptrEl: 'ptr',
ptrEl: 'ptr',

// Number of pixels of panning until refresh
distanceToRefresh: 70,
// Number of pixels of panning until refresh
distanceToRefresh: 70,

// Pointer to function that does the loading and returns a promise
loadingFunction: false,
Expand All @@ -37,22 +37,22 @@ var WebPullToRefresh = (function () {
distance: 0,
startingPositionY: 0
};

/**
* Easy shortener for handling adding and removing body classes.
*/
var bodyClass = document.body.classList;

/**
* Initialize pull to refresh, hammer, and bind pan events.
*
*
* @param {object=} params - Setup parameters for pull to refresh
*/
var init = function( params ) {
params = params || {};
options = {
contentEl: params.contentEl || document.getElementById( defaults.contentEl ),
ptrEl: params.ptrEl || document.getElementById( defaults.ptrEl ),
contentEl: (params.contentEl && document.getElementById(params.contentEl)) || document.getElementById( defaults.contentEl ),
ptrEl: (params.ptrEl && document.getElementById(params.ptrEl)) || document.getElementById( defaults.ptrEl ),
distanceToRefresh: params.distanceToRefresh || defaults.distanceToRefresh,
loadingFunction: params.loadingFunction || defaults.loadingFunction,
resistance: params.resistance || defaults.resistance
Expand All @@ -74,7 +74,7 @@ var WebPullToRefresh = (function () {

/**
* Determine whether pan events should apply based on scroll position on panstart
*
*
* @param {object} e - Event object
*/
var _panStart = function(e) {
Expand All @@ -87,7 +87,7 @@ var WebPullToRefresh = (function () {

/**
* Handle element on screen movement when the pandown events is firing.
*
*
* @param {object} e - Event object
*/
var _panDown = function(e) {
Expand All @@ -104,7 +104,7 @@ var WebPullToRefresh = (function () {

/**
* Handle element on screen movement when the pandown events is firing.
*
*
* @param {object} e - Event object
*/
var _panUp = function(e) {
Expand Down Expand Up @@ -141,12 +141,12 @@ var WebPullToRefresh = (function () {
bodyClass.add( 'ptr-refresh' );
} else {
bodyClass.remove( 'ptr-refresh' );
}
}
};

/**
* Determine how to animate and position elements when the panend event fires.
*
*
* @param {object} e - Event object
*/
var _panEnd = function(e) {
Expand Down Expand Up @@ -210,4 +210,4 @@ var WebPullToRefresh = (function () {
init: init
}

})();
})();