locked
GestureRecognizer works well, until you scroll the list...

    Question

  • Hi all,

    I have a GestureRecognizer to detect a long press on the elements of a ListView, switching the ListView's tapBehavior from "invokeOnly" to "toggleSelect" when the long press is detected.

    Everything works as intended until I scroll the ListView: after such an interaction my GestureRecognizer will keep getting pointer events (which are listened by the ListView) but won't fire the "holding" event until the page is reloaded! It's like if scrolling the ListView would remove the GR's "holding" event listener...

    Does anyone know what I should do to make both functionnal?

    Tuesday, June 17, 2014 9:52 AM

Answers

  • You'll need to use one at a time. The ListViews ScrollViewer will handle gesture on its own. See my blog entry http://blogs.msdn.com/b/wsdevsol/archive/2013/02/16/where-did-all-my-gestures-go.aspx for a discussion of this. The details have changed a bit with Windows 8.1 but the general concept is the same.

    You can probably reset the GestureRecognizer by calling CompleteGesture on it then restarting. If not, try creating a new GestureRecognizer when you detect the situation. 

    Tuesday, June 17, 2014 2:57 PM
    Owner

All replies

  • You'll need to use one at a time. The ListViews ScrollViewer will handle gesture on its own. See my blog entry http://blogs.msdn.com/b/wsdevsol/archive/2013/02/16/where-did-all-my-gestures-go.aspx for a discussion of this. The details have changed a bit with Windows 8.1 but the general concept is the same.

    You can probably reset the GestureRecognizer by calling CompleteGesture on it then restarting. If not, try creating a new GestureRecognizer when you detect the situation. 

    Tuesday, June 17, 2014 2:57 PM
    Owner
  • Hi Rob,

    Thanks for your help, it's not elegant but it works!

    For those who would search how to do it, here is what I've done in my page's ready function:

    document.querySelector('.myListViewClass .win-viewport').addEventListener('scroll', function (evt) {
        if (page._grReinitTimer) clearTimeout(page._grReinitTimer);
        page._grReinitTimer = setTimeout(function () {
            page._gr.completeGesture();
        }, 500);
    });


    Wednesday, June 18, 2014 8:23 AM