@@ -1571,12 +1571,14 @@ class Element {
1571
1571
// For details, see https://github.com/processing/p5.js/issues/3087.
1572
1572
const eventPrependedFxn = function ( event ) {
1573
1573
this . _pInst . mouseIsPressed = true ;
1574
+ this . _pInst . _activePointers . set ( e . pointerId , e ) ;
1574
1575
this . _pInst . _setMouseButton ( event ) ;
1576
+ this . _pInst . _updatePointerCoords ( e ) ;
1575
1577
// Pass along the return-value of the callback:
1576
1578
return fxn . call ( this , event ) ;
1577
1579
} ;
1578
1580
// Pass along the event-prepended form of the callback.
1579
- Element . _adjustListener ( 'mousedown ' , eventPrependedFxn , this ) ;
1581
+ Element . _adjustListener ( 'pointerdown ' , eventPrependedFxn , this ) ;
1580
1582
return this ;
1581
1583
}
1582
1584
@@ -1746,7 +1748,7 @@ class Element {
1746
1748
* </div>
1747
1749
*/
1748
1750
mouseReleased ( fxn ) {
1749
- Element . _adjustListener ( 'mouseup ' , fxn , this ) ;
1751
+ Element . _adjustListener ( 'pointerup ' , fxn , this ) ;
1750
1752
return this ;
1751
1753
}
1752
1754
@@ -1831,7 +1833,7 @@ class Element {
1831
1833
* </div>
1832
1834
*/
1833
1835
mouseMoved ( fxn ) {
1834
- Element . _adjustListener ( 'mousemove ' , fxn , this ) ;
1836
+ Element . _adjustListener ( 'pointermove ' , fxn , this ) ;
1835
1837
return this ;
1836
1838
}
1837
1839
@@ -1872,7 +1874,7 @@ class Element {
1872
1874
* </div>
1873
1875
*/
1874
1876
mouseOver ( fxn ) {
1875
- Element . _adjustListener ( 'mouseover ' , fxn , this ) ;
1877
+ Element . _adjustListener ( 'pointerover ' , fxn , this ) ;
1876
1878
return this ;
1877
1879
}
1878
1880
@@ -1913,140 +1915,11 @@ class Element {
1913
1915
* </div>
1914
1916
*/
1915
1917
mouseOut ( fxn ) {
1916
- Element . _adjustListener ( 'mouseout ' , fxn , this ) ;
1918
+ Element . _adjustListener ( 'pointerout ' , fxn , this ) ;
1917
1919
return this ;
1918
1920
}
1919
1921
1920
- /**
1921
- * Calls a function when the element is touched.
1922
- *
1923
- * Calling `myElement.touchStarted(false)` disables the function.
1924
- *
1925
- * Note: Touch functions only work on mobile devices.
1926
- *
1927
- * @param {Function|Boolean } fxn function to call when the touch
1928
- * starts.
1929
- * `false` disables the function.
1930
- * @chainable
1931
- *
1932
- * @example
1933
- * <div>
1934
- * <code>
1935
- * function setup() {
1936
- * // Create a canvas element and
1937
- * // assign it to cnv.
1938
- * let cnv = createCanvas(100, 100);
1939
- *
1940
- * background(200);
1941
- *
1942
- * // Call randomColor() when the
1943
- * // user touches the canvas.
1944
- * cnv.touchStarted(randomColor);
1945
- *
1946
- * describe('A gray square changes color when the user touches the canvas.');
1947
- * }
1948
- *
1949
- * // Paint the background either
1950
- * // red, yellow, blue, or green.
1951
- * function randomColor() {
1952
- * let c = random(['red', 'yellow', 'blue', 'green']);
1953
- * background(c);
1954
- * }
1955
- * </code>
1956
- * </div>
1957
- */
1958
- touchStarted ( fxn ) {
1959
- Element . _adjustListener ( 'touchstart' , fxn , this ) ;
1960
- return this ;
1961
- }
1962
-
1963
- /**
1964
- * Calls a function when the user touches the element and moves.
1965
- *
1966
- * Calling `myElement.touchMoved(false)` disables the function.
1967
- *
1968
- * Note: Touch functions only work on mobile devices.
1969
- *
1970
- * @param {Function|Boolean } fxn function to call when the touch
1971
- * moves over the element.
1972
- * `false` disables the function.
1973
- * @chainable
1974
- * @example
1975
- * <div>
1976
- * <code>
1977
- * function setup() {
1978
- * // Create a canvas element and
1979
- * // assign it to cnv.
1980
- * let cnv = createCanvas(100, 100);
1981
- *
1982
- * background(200);
1983
- *
1984
- * // Call randomColor() when the
1985
- * // user touches the canvas
1986
- * // and moves.
1987
- * cnv.touchMoved(randomColor);
1988
- *
1989
- * describe('A gray square changes color when the user touches the canvas and moves.');
1990
- * }
1991
- *
1992
- * // Paint the background either
1993
- * // red, yellow, blue, or green.
1994
- * function randomColor() {
1995
- * let c = random(['red', 'yellow', 'blue', 'green']);
1996
- * background(c);
1997
- * }
1998
- * </code>
1999
- * </div>
2000
- */
2001
- touchMoved ( fxn ) {
2002
- Element . _adjustListener ( 'touchmove' , fxn , this ) ;
2003
- return this ;
2004
- }
2005
-
2006
- /**
2007
- * Calls a function when the user stops touching the element.
2008
- *
2009
- * Calling `myElement.touchMoved(false)` disables the function.
2010
- *
2011
- * Note: Touch functions only work on mobile devices.
2012
- *
2013
- * @param {Function|Boolean } fxn function to call when the touch
2014
- * ends.
2015
- * `false` disables the function.
2016
- * @chainable
2017
- * @example
2018
- * <div>
2019
- * <code>
2020
- * function setup() {
2021
- * // Create a canvas element and
2022
- * // assign it to cnv.
2023
- * let cnv = createCanvas(100, 100);
2024
- *
2025
- * background(200);
2026
- *
2027
- * // Call randomColor() when the
2028
- * // user touches the canvas,
2029
- * // then lifts their finger.
2030
- * cnv.touchEnded(randomColor);
2031
- *
2032
- * describe('A gray square changes color when the user touches the canvas, then lifts their finger.');
2033
- * }
2034
- *
2035
- * // Paint the background either
2036
- * // red, yellow, blue, or green.
2037
- * function randomColor() {
2038
- * let c = random(['red', 'yellow', 'blue', 'green']);
2039
- * background(c);
2040
- * }
2041
- * </code>
2042
- * </div>
2043
- */
2044
- touchEnded ( fxn ) {
2045
- Element . _adjustListener ( 'touchend' , fxn , this ) ;
2046
- return this ;
2047
- }
2048
-
2049
- /**
1922
+ /**
2050
1923
* Calls a function when a file is dragged over the element.
2051
1924
*
2052
1925
* Calling `myElement.dragOver(false)` disables the function.
0 commit comments