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

Keep the touch listener from being added every time the disable scrolling method is called #1

Merged
merged 5 commits into from
Mar 7, 2014
Merged
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: 20 additions & 12 deletions index.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,34 @@ WuiView.prototype.close = function () {
};

/**
* disableScrolling
* set scrolling listener
*/
WuiView.prototype.disableScrolling = function () {
this.allowDomEvents();
function setScrolling(view, value) {
if (view.scrollingDisabled === undefined) {
view.allowDomEvents();

this.scrollingDisabled = true;
var that = this;
view.on('dom.touchmove', function (e) {
// TODO: this does not work on a desktop

this.on('dom.touchmove', function (e) {
// note: this does not work on a desktop
if (view.scrollingDisabled) {
e.preventDefault();
}
});
}

view.scrollingDisabled = value;
}

if (that.scrollingDisabled) {
e.preventDefault();
}
});
/**
* disableScrolling
*/
WuiView.prototype.disableScrolling = function () {
setScrolling(this, true);
};

/**
* enableScrolling
*/
WuiView.prototype.enableScrolling = function () {
this.scrollingDisabled = false;
setScrolling(this, false);
};