Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit341708e

Browse files
fix(pointer): use0.5 as default value forPointerEvent.pressure (#1262)
Co-authored-by: Philipp Fritsche <ph.fritsche@gmail.com>
1 parentf8f8ff7 commit341708e

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

‎src/event/createEvent.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,14 @@ function initPointerEvent(
256256
twist,
257257
pointerType,
258258
isPrimary,
259+
buttons,
259260
}:PointerEventInit,
260261
){
261262
assignProps(event,{
262263
pointerId:sanitizeNumber(pointerId),
263264
width:sanitizeNumber(width??1),
264265
height:sanitizeNumber(height??1),
265-
pressure:sanitizeNumber(pressure),
266+
pressure:sanitizeNumber(pressure??(buttons ?0.5 :0)),
266267
tangentialPressure:sanitizeNumber(tangentialPressure),
267268
tiltX:sanitizeNumber(tiltX),
268269
tiltY:sanitizeNumber(tiltY),

‎tests/pointer/index.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,24 @@ test('suppress mouse events per preventDefault on pointerdown', async () => {
267267
expect(eventWasFired('mousemove')).toBe(false)
268268
expect(eventWasFired('mouseup')).toBe(false)
269269
})
270+
271+
test('apply default event properties',async()=>{
272+
const{element, user, getEvents, clearEventCalls}=setup(`<div></div>`)
273+
274+
awaituser.pointer({target:element})
275+
276+
expect(getEvents('pointermove')[0]).toEqual(expect.objectContaining({
277+
width:1,
278+
height:1,
279+
pressure:0,
280+
}))
281+
282+
clearEventCalls()
283+
awaituser.pointer([{keys:'[MouseLeft>]'},{coords:{x:20}}])
284+
285+
expect(getEvents('pointermove')[0]).toEqual(expect.objectContaining({
286+
width:1,
287+
height:1,
288+
pressure:0.5,
289+
}))
290+
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp