Use touch-action: pan-y to fix DnD vs scroll (#2350)
* Fix handleTouchMove not handling leaving elements * Fix DnD vs scroll on mobile
This commit is contained in:
		
							parent
							
								
									0968c77bdf
								
							
						
					
					
						commit
						1dc4018a3c
					
				@ -18,7 +18,7 @@
 | 
			
		||||
@media (max-width: 768px) {
 | 
			
		||||
  .draggable {
 | 
			
		||||
    /* https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action */
 | 
			
		||||
    touch-action: none;
 | 
			
		||||
    touch-action: pan-y;
 | 
			
		||||
    user-select: none;
 | 
			
		||||
    -webkit-user-select: none;
 | 
			
		||||
    -moz-user-select: none;
 | 
			
		||||
 | 
			
		||||
@ -123,14 +123,18 @@ export function useDndHandlers (index) {
 | 
			
		||||
      if (isTouchDragging) {
 | 
			
		||||
        // Find the element under the touch point
 | 
			
		||||
        const elementUnderTouch = document.elementFromPoint(touch.clientX, touch.clientY)
 | 
			
		||||
        if (elementUnderTouch) {
 | 
			
		||||
          const element = elementUnderTouch.closest('[data-index]')
 | 
			
		||||
          if (element) {
 | 
			
		||||
            const elementIndex = parseInt(element.dataset.index)
 | 
			
		||||
            if (elementIndex !== index) {
 | 
			
		||||
              dispatch({ type: DRAG_ENTER, index: elementIndex })
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        if (!elementUnderTouch) {
 | 
			
		||||
          return dispatch({ type: DRAG_LEAVE })
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const element = elementUnderTouch.closest('[data-index]')
 | 
			
		||||
        if (!element) {
 | 
			
		||||
          return dispatch({ type: DRAG_LEAVE })
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const elementIndex = parseInt(element.dataset.index)
 | 
			
		||||
        if (elementIndex !== index) {
 | 
			
		||||
          dispatch({ type: DRAG_ENTER, index: elementIndex })
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user