2

I have a horizontal scrolling element like this:

enter image description here

<ul class="playlist">
   <li>element1</li>
   <li>element2</li>
   .
   .
   <li>elementN</li>
</ul>

https://jsfiddle.net/3um9n6zk/

On a touch device, the user can then swipe-scroll and select an element.

I'd also like to be able to pinch the container to adjust the elements' scale. Using Hammer 2.0:

function pinchMe($container) {

    var options={
        touchAction:"pan-x"
 //     touchAction:"none"
    };
    var hammer = new Hammer.Manager($container[0], options),
        cInitScale;

    hammer
        .add( [
                new Hammer.Pinch({ threshold: 0 }),
                new Hammer.Tap(),
                new Hammer.Press()
        ])
        .on("pinchstart", function(e) {
                cInitScale = VSIZE;
                window.console.log("pinch start is ",VSIZE);
        })
        .on("pinch pinchmove", function(ev) {
            // if pan-x is activated, I dont' get these events until a pinchend
            window.console.log("pinch");
            resizeHot (cInitScale * ev.scale);
        })
        .on("tap", tapHandler);
        .on("press", pressHandler);
}

My problem is, once I use Hammer to control the pinch, the (native html) scrolling no longer works.

  • When I set pan-x as the Touch Action, no pinch events are sent after pinchstart, only when the pinch ends I get an event. I suspect the intermediate events are ignored as part of a scroll (even though 2 touches are pressed)

  • When I don't set pan-x, the scrolling doesn't work(as expected) and the pinch does work

Is it possible to have both things at once?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
rupps
  • 9,712
  • 4
  • 55
  • 95
  • 1
    I believe this [answer](http://stackoverflow.com/a/11183333/3855179) from one of the stack might interest you and help you get a fresh way to look around this problem – Sumit Surana Feb 19 '16 at 17:25
  • is certainly my next try if i'm not able to accomplish it through Hammer, as I'm already using the library for other stuff – rupps Feb 19 '16 at 17:31

1 Answers1

0

It seems you have a typo there. The option is called touchAction, singular. The value of "pan-x" that you gave it is correct in your case and will allow you to scroll horizontally.

I've updated your fiddle to try it out: https://jsfiddle.net/3um9n6zk/1/

Andrei Vajna II
  • 4,642
  • 5
  • 35
  • 38
  • hi! thanks for your answer, It was indeed a typo here, but my code had it right. I have updated the question, my problem is that `pan-x` interferes with the `pinchmove` events – rupps Feb 22 '16 at 17:12