Skip to content

Mobile Error on method onEvent (with correction) #45

@emitategh

Description

@emitategh

Hi, I was getting an "undefined getX" or "undefined getY"
Because e.originalEvent.targetTouches had length 0 on last touchevent, that caused canvas to be
wiped clear.

Sketch.prototype.onEvent = function(e) {
      console.log(e.originalEvent.targetTouches);
      if (e.originalEvent && e.originalEvent.targetTouches) {
        if (e.originalEvent.targetTouches.length){ ///-----------> Added
          e.pageX = e.originalEvent.targetTouches[0].pageX;
          e.pageY = e.originalEvent.targetTouches[0].pageY;
        }
      }
      $.sketch.tools[$(this).data('sketch').tool].onEvent.call($(this).data('sketch'), e);
      e.preventDefault();
      return false;
    };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions