Search code examples
javascriptiossvgevent-handlingsvg-edit

iOS 11.3 causes drawing canvas to pan/scroll with selection with Method-Draw / SVG-Edit


We use MethodDraw which is a fork of SVG-Edit. Ever since the last iOS update on the iPad or iPhone, the screen scrolls when you try to draw a line on the drawing canvas. When making a simple selection, the screen pans around making it unable to use. There is a bug report on MethodDraw already, but it sounds like MethodDraw is no longer being maintained and updated.

To reproduce, view this page with a iPad or iPhone running iOS 11.3 or later: http://editor.method.ac/ and try to use the pencil to draw a line - you will see the screen move and it's almost impossible to use the app.

Searching the web for a solution, I found a similar issue but I'm still not sure how to patch MethodDraw to fix it. See webkit.org: Bug 184250 - Unable to call event.preventDefault in dynamically added event listener

I believe it has something to do with dynamic event handlers.


Solution

  • This is the function we used to correct the problem. We call this function on page load.

    function handleAppleDevice(){
        var iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
        if(iOS){
            $('body').css('position','fixed');
        }
    }