1(function() { 2 'use strict'; 3 4 const app = angular.module('app'); 5 6 app.directive('scrollHandler', function () { 7 return { 8 restrict: 'A', 9 link: function (scope, element) { 10 let isDown = false; 11 let startX; 12 let scrollLeft; 13 let hasMoved = false; 14 let isDragging = false; 15 16 function clearState() { 17 isDown = false; 18 startX = null; 19 scrollLeft = null; 20 } 21 22 element.on('mousedown', function(e) { 23 if (e.button !== 0) return false; 24 clearState(); 25 isDown = true; 26 hasMoved = false; 27 isDragging = false; 28 startX = e.pageX - element[0].offsetLeft; 29 scrollLeft = element[0].scrollLeft; 30 return false; 31 }); 32 33 element.on('mouseleave', function() { 34 clearState(); 35 return false; 36 }); 37 38 angular.element(document).on('mouseup', function(e) { 39 if (isDown) { 40 e.preventDefault(); 41 e.stopPropagation(); 42 if (hasMoved) { 43 isDragging = true; 44 isDragging = false; 45 } 46 clearState(); 47 } 48 return false; 49 }); 50 51 angular.element(document).on('mousemove', function(e) { 52 if (!isDown) return false; 53 e.preventDefault(); 54 e.stopPropagation(); 55 hasMoved = true; 56 var x = e.pageX - element[0].offsetLeft; 57 var walk = (x - startX) * 2; 58 element[0].scrollLeft = scrollLeft - walk; 59 return false; 60 }); 61 62 var parentElement = angular.element(element).parent()[0]; 63 64 parentElement.addEventListener('click', function(e) { 65 if (isDragging) { 66 e.preventDefault(); 67 e.stopPropagation(); 68 e.stopImmediatePropagation(); 69 return false; 70 } 71 }, true); 72 73 scope.$on('$destroy', function() { 74 clearState(); 75 hasMoved = false; 76 isDragging = false; 77 angular.element(document).off('mouseup'); 78 angular.element(document).off('mousemove'); 79 parentElement.removeEventListener('click', parentElement.clickHandler, true); 80 }); 81 } 82 }; 83 }); 84})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.