Skip to content

Commit 575cc3a

Browse files
ArecsuMugen87
andauthored
docs: Offscreen Canvas fix touch pick and 2 fingers interactions (#29983)
* docs: Offscreen Canvas fix touch pick and 2 fingers interactions * Update offscreencanvas-w-orbitcontrols.html --------- Co-authored-by: Michael Herzog <[email protected]>
1 parent 00fa06f commit 575cc3a

File tree

5 files changed

+36
-1
lines changed

5 files changed

+36
-1
lines changed

manual/en/offscreencanvas.html

+7
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ <h1>OffscreenCanvas</h1>
815815
'pointerType',
816816
'clientX',
817817
'clientY',
818+
'pointerId',
818819
'pageX',
819820
'pageY',
820821
]);
@@ -853,13 +854,19 @@ <h1>OffscreenCanvas</h1>
853854
}
854855

855856
function touchEventHandler(event, sendFn) {
857+
// preventDefault() fixes mousemove, mouseup and mousedown
858+
// firing when doing a simple touchup touchdown
859+
// Happens only at offscreen canvas
860+
event.preventDefault();
856861
const touches = [];
857862
const data = {type: event.type, touches};
858863
for (let i = 0; i &lt; event.touches.length; ++i) {
859864
const touch = event.touches[i];
860865
touches.push({
861866
pageX: touch.pageX,
862867
pageY: touch.pageY,
868+
clientX: touch.clientX,
869+
clientY: touch.clientY,
863870
});
864871
}
865872
sendFn(data);

manual/examples/offscreencanvas-w-orbitcontrols.html

+8-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
'pointerType',
3535
'clientX',
3636
'clientY',
37+
'pointerId',
3738
'pageX',
3839
'pageY',
3940
] );
@@ -84,7 +85,11 @@
8485
}
8586

8687
function touchEventHandler( event, sendFn ) {
87-
88+
89+
// preventDefault() fixes mousemove, mouseup and mousedown
90+
// firing at touch events when doing a simple touchup touchdown
91+
// Happens only at offscreen canvas
92+
event.preventDefault();
8893
const touches = [];
8994
const data = { type: event.type, touches };
9095
for ( let i = 0; i < event.touches.length; ++ i ) {
@@ -93,6 +98,8 @@
9398
touches.push( {
9499
pageX: touch.pageX,
95100
pageY: touch.pageY,
101+
clientX: touch.clientX,
102+
clientY: touch.clientY,
96103
} );
97104

98105
}

manual/ja/offscreencanvas.html

+7
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ <h1>のOffscreenCanvas</h1>
767767
'pointerType',
768768
'clientX',
769769
'clientY',
770+
'pointerId',
770771
'pageX',
771772
'pageY',
772773
]);
@@ -805,13 +806,19 @@ <h1>のOffscreenCanvas</h1>
805806
}
806807

807808
function touchEventHandler(event, sendFn) {
809+
// preventDefault() fixes mousemove, mouseup and mousedown
810+
// firing when doing a simple touchup touchdown
811+
// Happens only at offscreen canvas
812+
event.preventDefault();
808813
const touches = [];
809814
const data = {type: event.type, touches};
810815
for (let i = 0; i &lt; event.touches.length; ++i) {
811816
const touch = event.touches[i];
812817
touches.push({
813818
pageX: touch.pageX,
814819
pageY: touch.pageY,
820+
clientX: touch.clientX,
821+
clientY: touch.clientY,
815822
});
816823
}
817824
sendFn(data);

manual/ko/offscreencanvas.html

+7
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ <h1>OffscreenCanvas</h1>
717717
'pointerType',
718718
'clientX',
719719
'clientY',
720+
'pointerId',
720721
'pageX',
721722
'pageY',
722723
]);
@@ -755,13 +756,19 @@ <h1>OffscreenCanvas</h1>
755756
}
756757

757758
function touchEventHandler(event, sendFn) {
759+
// preventDefault() fixes mousemove, mouseup and mousedown
760+
// firing when doing a simple touchup touchdown
761+
// Happens only at offscreen canvas
762+
event.preventDefault();
758763
const touches = [];
759764
const data = { type: event.type, touches };
760765
for (let i = 0; i &lt; event.touches.length; ++i) {
761766
const touch = event.touches[i];
762767
touches.push({
763768
pageX: touch.pageX,
764769
pageY: touch.pageY,
770+
clientX: touch.clientX,
771+
clientY: touch.clientY,
765772
});
766773
}
767774
sendFn(data);

manual/ru/offscreencanvas.html

+7
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ <h1>OffscreenCanvas</h1>
748748
'pointerType',
749749
'clientX',
750750
'clientY',
751+
'pointerId',
751752
'pageX',
752753
'pageY',
753754
]);
@@ -786,13 +787,19 @@ <h1>OffscreenCanvas</h1>
786787
}
787788

788789
function touchEventHandler(event, sendFn) {
790+
// preventDefault() fixes mousemove, mouseup and mousedown
791+
// firing when doing a simple touchup touchdown
792+
// Happens only at offscreen canvas
793+
event.preventDefault();
789794
const touches = [];
790795
const data = {type: event.type, touches};
791796
for (let i = 0; i &lt; event.touches.length; ++i) {
792797
const touch = event.touches[i];
793798
touches.push({
794799
pageX: touch.pageX,
795800
pageY: touch.pageY,
801+
clientX: touch.clientX,
802+
clientY: touch.clientY,
796803
});
797804
}
798805
sendFn(data);

0 commit comments

Comments
 (0)