Skip to content

Commit db44392

Browse files
authored
Swipe: add test to ensure that it ignores pinch events (twbs#35161)
1 parent d7dec12 commit db44392

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

js/src/util/swipe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import EventHandler from '../dom/event-handler'
22
import { execute, typeCheckConfig } from './index'
33

4+
const NAME = 'swipe'
45
const EVENT_KEY = '.bs.swipe'
56
const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`
67
const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`
@@ -11,7 +12,6 @@ const POINTER_TYPE_TOUCH = 'touch'
1112
const POINTER_TYPE_PEN = 'pen'
1213
const CLASS_NAME_POINTER_EVENT = 'pointer-event'
1314
const SWIPE_THRESHOLD = 40
14-
const NAME = 'swipe'
1515

1616
const Default = {
1717
leftCallback: null,

js/tests/unit/util/swipe.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,25 @@ describe('Swipe', () => {
151151
})
152152

153153
describe('Functionality on PointerEvents', () => {
154+
it('should not allow pinch with touch events', () => {
155+
Simulator.setType('touch')
156+
clearPointerEvents()
157+
deleteDocumentElementOntouchstart()
158+
159+
const swipe = new Swipe(swipeEl)
160+
spyOn(swipe, '_handleSwipe')
161+
162+
mockSwipeGesture(swipeEl, {
163+
pos: [300, 10],
164+
deltaX: -300,
165+
deltaY: 0,
166+
touches: 2
167+
})
168+
169+
restorePointerEvents()
170+
expect(swipe._handleSwipe).not.toHaveBeenCalled()
171+
})
172+
154173
it('should allow swipeRight and call "rightCallback" with pointer events', done => {
155174
if (!supportPointerEvent) {
156175
expect().nothing()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy