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

Add disableMobile and enableMobile public functions #763

Open
wants to merge 1 commit 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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,14 @@ When `force` is set to `true`, skrollr will jump to the new position without any

Returns if skrollr runs in mobile mode (see also `mobileCheck` option).

### disableMobile()

Disable mobile event catching, which means skrollr won't move but the click/tap/drag event will bubble up.

### enableMobile()

Re-enable mobile event catching.

### animateTo(top[, options])

Animates the scroll position from current position to `top`. Possible `options` are
Expand Down
14 changes: 14 additions & 0 deletions src/skrollr.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@

//Finds all gradients.
var rxGradient = /[a-z\-]+-gradient/g;

//If mobile event catching is enabled
var mobileEnabled = true;

//Vendor prefix. Will be set once skrollr gets initialized.
var theCSSPrefix = '';
Expand Down Expand Up @@ -647,6 +650,14 @@
return _instance;
};

Skrollr.prototype.disableMobile = function() {
mobileEnabled = false;
};

Skrollr.prototype.enableMobile = function() {
mobileEnabled = true;
};

Skrollr.prototype.destroy = function() {
var cancelAnimFrame = polyfillCAF();
cancelAnimFrame(_animFrame);
Expand Down Expand Up @@ -713,6 +724,9 @@
var deltaTime;

_addEvent(documentElement, [EVENT_TOUCHSTART, EVENT_TOUCHMOVE, EVENT_TOUCHCANCEL, EVENT_TOUCHEND].join(' '), function(e) {
if (!mobileEnabled)
return true;

var touch = e.changedTouches[0];

currentElement = e.target;
Expand Down