0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-01 13:24:25 +01:00

Swipe: add test to ensure that it ignores pinch events (#35161)

This commit is contained in:
GeoSot 2021-10-12 15:48:19 +03:00 committed by GitHub
parent d7dec124eb
commit db44392bda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import EventHandler from '../dom/event-handler' import EventHandler from '../dom/event-handler'
import { execute, typeCheckConfig } from './index' import { execute, typeCheckConfig } from './index'
const NAME = 'swipe'
const EVENT_KEY = '.bs.swipe' const EVENT_KEY = '.bs.swipe'
const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}` const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`
const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}` const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`
@ -11,7 +12,6 @@ const POINTER_TYPE_TOUCH = 'touch'
const POINTER_TYPE_PEN = 'pen' const POINTER_TYPE_PEN = 'pen'
const CLASS_NAME_POINTER_EVENT = 'pointer-event' const CLASS_NAME_POINTER_EVENT = 'pointer-event'
const SWIPE_THRESHOLD = 40 const SWIPE_THRESHOLD = 40
const NAME = 'swipe'
const Default = { const Default = {
leftCallback: null, leftCallback: null,

View File

@ -151,6 +151,25 @@ describe('Swipe', () => {
}) })
describe('Functionality on PointerEvents', () => { describe('Functionality on PointerEvents', () => {
it('should not allow pinch with touch events', () => {
Simulator.setType('touch')
clearPointerEvents()
deleteDocumentElementOntouchstart()
const swipe = new Swipe(swipeEl)
spyOn(swipe, '_handleSwipe')
mockSwipeGesture(swipeEl, {
pos: [300, 10],
deltaX: -300,
deltaY: 0,
touches: 2
})
restorePointerEvents()
expect(swipe._handleSwipe).not.toHaveBeenCalled()
})
it('should allow swipeRight and call "rightCallback" with pointer events', done => { it('should allow swipeRight and call "rightCallback" with pointer events', done => {
if (!supportPointerEvent) { if (!supportPointerEvent) {
expect().nothing() expect().nothing()