From 0b7ab75512d7f81e46e1bc540bf0e6e4713af5cf Mon Sep 17 00:00:00 2001 From: Shivam Dave Date: Wed, 2 Sep 2015 10:20:49 -0700 Subject: [PATCH] [Mobile] Comments Added comments to destroy and remaining MCTPinch functions. --- .../plot-reborn/src/directives/MCTPinch.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/platform/features/plot-reborn/src/directives/MCTPinch.js b/platform/features/plot-reborn/src/directives/MCTPinch.js index 379523169a..2c8ce8ad1b 100644 --- a/platform/features/plot-reborn/src/directives/MCTPinch.js +++ b/platform/features/plot-reborn/src/directives/MCTPinch.js @@ -51,7 +51,7 @@ define( } // Calculates the midpoint between two given - // coordinates + // coordinates and returns it as coordinate object function calculateMidpoint(coordOne, coordTwo) { return { clientX: (coordOne.clientX + coordTwo.clientX) / 2, @@ -211,17 +211,29 @@ define( } // Stop checking for touch when scope is destroyed + // (when user navigates away from graph). $scope.$on("$destroy", function () { + + // All elements' event listeners are + // removed element.off('touchstart', touchStart); element.off('touchmove', touchChange); element.off('touchend', touchEnd); element.off('touchcancel', touchEnd); + + // If for some reason, midtouch the + // user is navigated away, set pan/pinch + // statuses to false + isPan = false; + isPinch = false; }); } return { + // MCTPinch is treated as an attribute restrict: "A", - // Link with the provided function + + // Link with the provided function above link: link }; }