Image display goes haywire when user tries to zoom (double-tap or pinch-open)

22 views
Skip to first unread message

JPL

unread,
Jun 30, 2015, 12:01:09 PM6/30/15
to slimbox...@googlegroups.com


All is working fine on a smartphone using a version of Slimbox modified to resize the image as described in the post below: image maxheight & maxwidth.


However, if the user double-taps for fit-to-width or pinches-open to zoom in, the display goes wrong. Please see the attached screenshot:





The view does zoom in, but the image moves right and cannot be scrolled at all.  There is presumably a conflict between what Slimbox and the browser are doing - not surprising really.

I would like to intercept the double-tap, pinch-open and pinch-close events so that they do nothing.  Slimbox 2.0.5 adds the key down events thus (Line 153):
        $(document)[fn]("keydown", keyDown);
Presumably the required event handlers be added in a similar way directly after this statement.  Is this the best approach here, and if so what is the best way to program it?

JPL

JPL

unread,
Jul 1, 2015, 9:03:00 AM7/1/15
to slimbox...@googlegroups.com

A handler for two touches within a defined time period seems to fix this for both double-tap and pinch-to-zoom:

    dblTapStartTime = 0;
    document.body.addEventListener("touchstart", dblTap, false);

    function dblTap(event) {
        var now = +(new Date());
        if (now < (dblTapStartTime + 500)) {
            event.preventDefault();
        }
        dblTapStartTime = now;
    }


JPL

Reply all
Reply to author
Forward
0 new messages