Provides directives and service to prevent touchmove default behaviour for touch devices (ie. bounce on overscroll in IOS).

Usage

Use ui-prevent-touchmove-defaults directive on root element of your app:

<body ng-app='myApp' ui-prevent-touchmove-defaults>
  <!-- ... -->
</body>

Doing so touchmove.preventDefault logic for inner elements is inverted, so any touchmove default behaviour is automatically prevented.

If you wish to allow the default behaviour, for example to allow inner elements to scroll, you have to explicitly mark an event to allow touchmove default.

Mobile Angular UI already handles this for scrollable elements, so you don't have to do anything in order to support scroll.

If you wish to allow touchmove defaults for certain element under certain conditions you can use the allowTouchmoveDefault service.

ie.

// always allow touchmove default for an element
allowTouchmoveDefault(myelem);
// allow touchmove default for an element only under certain conditions
allowTouchmoveDefault(myelem, function(touchmove){
  return touchmove.pageY > 100;
});

    Bind a listener to an element to allow touchmove default behaviour when touchmove happens inside the bound element.

    You can also provide a function to decide when to allow and when to prevent it.

    // always allow touchmove default
    allowTouchmoveDefault(myelem);
    
    // allow touchmove default only under certain conditions
    allowTouchmoveDefault(myelem, function(touchmove){
      return touchmove.pageY > 100;
    });
    
    ParamTypeDescription
    elementElement | $element

    The element to bind.

    conditionfunction

    A function(touchmove)⟶boolean to decide whether to allow default behavior or not.


    comments powered by Disqus