angular-ui/ui-grid

Moving columns on iPad does not work (e.pageX, e.pageY are not defined)

Open

#4.400 aberto em 18 de set. de 2015

Ver no GitHub
 (1 comment) (0 reactions) (0 assignees)JavaScript (2.496 forks)batch import
good first issuegrid-move-columnstype: bug

Métricas do repositório

Stars
 (5.395 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

When you try to move a column on iPad (try Column Moving demo in Tutorial) it just does not work. The problem is that e.pageX, e.pageY are not defined in 'touch...' events. You have to instead use this code:

var pointerEventToXY = function(e){
        var out = {
          x: 0, 
          y: 0
        };

        if (e.type == 'touchstart' || e.type == 'touchmove' || e.type == 'touchend' || e.type == 'touchcancel'){
            var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
            out.x = touch.pageX;
            out.y = touch.pageY;
        } 
        else if (e.type == 'mousedown' || e.type == 'mouseup' || e.type == 'mousemove' || e.type == 'mouseover'|| e.type == 'mouseout' || e.type == 'mouseenter' || e.type == 'mouseleave') {
            out.x = e.pageX;
            out.y = e.pageY;
        }

        return out;
    };

And you call it like this:

    var pageXY = pointerEventToXY(e);
    var pageX = pageXY.x;
    var pageY = pageXY.y;

I would recommend looking for all instances of e.pageX and e.pageY (I found 5 in current version) and replace them with the code above.

Guia do colaborador