Search code examples
javascriptangularjsangular-ui-gridui-grid

How can I do column move in ui-grid on tap & hold?


How can I do column move in ui-grid on tap & hold?

I am using ui-grid for touch devices, so it requires to move columns by tap & hold on grid column header, is anyone has idea how to overcome this problem.


Solution

  • Hi Mayank you can do something like this way.

    animateElement(function(evt)
            grid.scrollContainers($scope.$parent.containerId, scrollEvent, evt);
    });
    
    element.on('touchstart', touchStart);
    element.on('touchend', touchEnd);
    
    var lastTouchEvent;
    var touchduration = 500;
    var touchTimer;
    
    var onlongtouch = function(){
        movableFn(lastTouchEvent);
    };
    
    var touchStart = function(event){
        lastTouchEvent = event;
        touchTimer = setTimeout(onlongtouch, touchduration);
    };
    
    var touchEnd = function(event){
        if(touchTimer){
           clearTimeout(touchTimer);
           touchTimer = null;
           return;
        }
    };
    

    I hope it works for you.