AngularJS Parent Getting Swipe with Child

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RockyMac
    New Member
    • May 2015
    • 1

    AngularJS Parent Getting Swipe with Child

    I am using child div that is swipebale inside parent div which is using ng-carousel for swipe.
    I am facing the problem that whenever i am trying to swipe child div ,parent div is also getting swiped.
    I tried stopPropagation (), preventDefault( ) it is not working.

    Please advice....Urgen t help appreciated.
  • Varsha1285
    New Member
    • Feb 2023
    • 16

    #2
    t sounds like you have a touch event propagation issue. stopPropagation () and preventDefault( ) are used to prevent the event from propagating to parent elements, but in your case, the event is still propagating to the parent div. Here are a few suggestions to try:

    Use the touch-action CSS property to control the touch behavior of your child div. For example, you could set touch-action: pan-y on the child div to only allow vertical scrolling within that element. This should prevent the touch events from propagating to the parent div.

    You can add an event listener to your child div that captures the touch events and prevents them from bubbling up to the parent div. For example:

    Comment

    • Varsha1285
      New Member
      • Feb 2023
      • 16

      #3
      To enable swipe functionality in an AngularJS parent component with a child component, you can make use of a third-party library such as HammerJS or ngTouch.

      Comment

      Working...