2

I made an iframe on the page and rotated it by transform.

    body.rotate iframe {
        transform: rotate(90deg);
        transform-origin: top right;
        position: absolute;
        top: 100%;
        right: 0;
        height:100vw;
        min-width:100vh;
    }

and tried to add swipe event on the page in an iframe.

    var el = document.getElementById('swipe');
    Hammer(el).on('swipeleft', next);
    Hammer(el).on('swiperight', prev);
    Hammer(el).on('doubletap', preview);

When I doubletap on div#swipe in the rotated iframe, preview() is triggered. but swipeleft and swiperight doesn't work.

2
  • If you doubletap on where the div#swipe would be without the rotation, does it work then?
    – Brilliand
    Commented Jul 24, 2020 at 18:29
  • doubletap always works but swipeleft and swiperight doesn't work when iframe is rotated.
    – webelf000
    Commented Jul 24, 2020 at 18:47

1 Answer 1

1

Please follow this guide.

var el = document.getElementById('swipe');
var mc = new Hammer(el);
mc.get('pan').set({ direction: Hammer.DIRECTION_ALL });
Hammer(el).on('swipeleft', next);
Hammer(el).on('swiperight', prev);
Hammer(el).on('doubletap', preview);

Not the answer you're looking for? Browse other questions tagged or ask your own question.