Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

feat(gestures): add ability to disable all gestures for perf #11246

Merged
merged 1 commit into from
Apr 23, 2018
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
18 changes: 17 additions & 1 deletion src/core/services/gesture/gesture.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ var HANDLERS = {};
* It contains normalized x and y coordinates from DOM events,
* as well as other information abstracted from the DOM.
*/
var pointer, lastPointer, forceSkipClickHijack = false, maxClickDistance = 6;
var pointer, lastPointer, maxClickDistance = 6;
var forceSkipClickHijack = false, disableAllGestures = false;

/**
* The position of the most recent click if that click was on a label element.
Expand Down Expand Up @@ -57,6 +58,18 @@ function MdGestureProvider() { }

MdGestureProvider.prototype = {

/**
* @ngdoc method
* @name $mdGestureProvider#disableAll
*
* @description
* Disable all gesture detection. This can be beneficial to application performance
* and memory usage.
*/
disableAll: function () {
disableAllGestures = true;
},

// Publish access to setter to configure a variable BEFORE the
// $mdGesture service is instantiated...
/**
Expand Down Expand Up @@ -531,6 +544,9 @@ function MdGestureHandler() {
* @ngInject
*/
function attachToDocument( $mdGesture, $$MdGestureHandler ) {
if (disableAllGestures) {
return;
}

// Polyfill document.contains for IE11.
// TODO: move to util
Expand Down