Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "use strict";
- var cancelled = false;
- angular.module('app',[])
- .directive('onLongPress', function($timeout) {
- return {
- restrict: 'A',
- link: function($scope, $elm, $attrs) {
- $elm.bind('touchstart', function(evt) {
- // Locally scoped variable that will keep track of the long press
- $scope.longPress = true;
- // We'll set a timeout for 600 ms for a long press
- $timeout(function() {
- if ($scope.longPress) {
- // If the touchend event hasn't fired,
- // apply the function given in on the element's on-long-press attribute
- $scope.$apply(function() {
- $scope.$eval($attrs.onLongPress)
- });
- }
- }, 1100);
- });
- $elm.bind('touchend', function(evt) {
- // Prevent the onLongPress event from firing
- $scope.longPress = false;
- // If there is an on-touch-end function attached to this element, apply it
- if ($attrs.onTouchEnd) {
- $scope.$apply(function() {
- $scope.$eval($attrs.onTouchEnd)
- });
- }
- });
- }
- };
- })
- .controller('MainCtrl', function($scope, OHService, $timeout){
- $scope.move = 0;
- $scope.wait = false;
- $scope.itemOnLongPress = function($itemName){
- $('#layer3').css('visibility','visible');
- var item = OHService.getItem($itemName);
- if (item) {
- console.log(item.state);
- }
- };
- $scope.itemOnTouchEnd = function(){
- $('#layer3').css('visibility','hidden');
- };
- $scope.changesize = function(){
- console.log("BajsOVER");
- console.log($scope.$$childHead.toggle)
- setTimeout(function()
- {
- $scope.$$childHead.toggle = false;
- }, 3000)
- };
- $scope.testing = function($item){
- console.log($scope.wait)
- if(!$scope.wait){
- $scope.wait = true;
- $timeout(function()
- {
- $scope.$$childHead.move = false;
- $scope.$$childHead.move2 = false;
- $scope.$$childHead.move3 = false;
- $scope.$$childHead.move4 = false;
- $scope.wait = false;
- console.log($item);
- }, 6000)
- }
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement