Advertisement
NisseDILLIGAF

Untitled

Feb 23rd, 2018
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. "use strict";
  2.  
  3. var cancelled = false;
  4.  
  5. angular.module('app',[])
  6. .directive('onLongPress', function($timeout) {
  7.     return {
  8.         restrict: 'A',
  9.         link: function($scope, $elm, $attrs) {
  10.             $elm.bind('touchstart', function(evt) {
  11.                 // Locally scoped variable that will keep track of the long press
  12.                 $scope.longPress = true;
  13.  
  14.                 // We'll set a timeout for 600 ms for a long press
  15.                 $timeout(function() {
  16.                     if ($scope.longPress) {
  17.                         // If the touchend event hasn't fired,
  18.                         // apply the function given in on the element's on-long-press attribute
  19.                         $scope.$apply(function() {
  20.                             $scope.$eval($attrs.onLongPress)
  21.                         });
  22.                     }
  23.                 }, 1100);
  24.             });
  25.  
  26.             $elm.bind('touchend', function(evt) {
  27.                 // Prevent the onLongPress event from firing
  28.                 $scope.longPress = false;
  29.                 // If there is an on-touch-end function attached to this element, apply it
  30.                 if ($attrs.onTouchEnd) {
  31.                     $scope.$apply(function() {
  32.                         $scope.$eval($attrs.onTouchEnd)
  33.                     });
  34.                 }
  35.             });
  36.         }
  37.     };
  38. })
  39. .controller('MainCtrl', function($scope, OHService, $timeout){
  40.   $scope.move = 0;
  41.   $scope.wait = false;
  42.   $scope.itemOnLongPress = function($itemName){
  43.     $('#layer3').css('visibility','visible');
  44.     var item = OHService.getItem($itemName);
  45.     if (item) {
  46.         console.log(item.state);
  47.     }
  48.  
  49.   };
  50.   $scope.itemOnTouchEnd = function(){
  51.     $('#layer3').css('visibility','hidden');
  52.   };
  53.   $scope.changesize = function(){
  54.     console.log("BajsOVER");
  55.     console.log($scope.$$childHead.toggle)
  56.     setTimeout(function()
  57.     {
  58.         $scope.$$childHead.toggle = false;
  59.  
  60.     }, 3000)
  61.  
  62.   };
  63.   $scope.testing = function($item){
  64.     console.log($scope.wait)
  65.     if(!$scope.wait){
  66.         $scope.wait = true;
  67.         $timeout(function()
  68.         {
  69.             $scope.$$childHead.move = false;
  70.             $scope.$$childHead.move2 = false;
  71.             $scope.$$childHead.move3 = false;
  72.             $scope.$$childHead.move4 = false;
  73.             $scope.wait = false;
  74.             console.log($item);
  75.  
  76.  
  77.         }, 6000)
  78.     }
  79.   };
  80. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement