每當用戶將鼠標指針移出元素時,都會調用p5.js中p5.Element的mouseOut()方法。它可以用於將事件偵聽器附加到元素。
用法:
mouseOut( fxn )
參數:該函數接受如上所述和以下描述的單個參數:
- fxn:每當將鼠標移離元素時,就會觸發該函數。還可以將false值傳遞給它,以防止觸發先前的函數。
以下示例說明了p5.js中的mouseOut()方法:
例:
Javascript
function setup() {
canv = createCanvas(550, 300);
textSize(20);
text("Move the mouse over the canvas " +
"to change its color", 20, 20);
canv.mouseOver(changeColor);
// Specify the callback function
// when the mouse is moved out of
// an element
canv.mouseOut(origColor);
}
function changeColor() {
background("green");
text("The mouse has been moved over " +
"the canvas!", 20, 60);
text("Move the mouse over the canvas " +
"to change its color", 20, 20);
}
function origColor() {
background("white");
text("The mouse has been moved off " +
"the canvas!", 20, 60);
text("Move the mouse over the canvas to " +
"change its color", 20, 20);
}
輸出:
在線編輯: https://editor.p5js.org/
環境設置: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
參考: https://p5js.org/reference/#/p5.Element/mouseOut
相關用法
- JQuery mouseout()用法及代碼示例
- p5.js Element class()用法及代碼示例
- p5.js Element addClass()用法及代碼示例
- p5.js Element id()用法及代碼示例
- p5.js Element removeClass()用法及代碼示例
- p5.js Element mouseOver()用法及代碼示例
- p5.js Element hasClass()用法及代碼示例
- p5.js Element toggleClass()用法及代碼示例
- Lodash _.method()用法及代碼示例
- Node.js Http2ServerRequest.method用法及代碼示例
- Node.js http.IncomingMessage.method用法及代碼示例
注:本文由純淨天空篩選整理自sayantanm19大神的英文原創作品 p5.js Element mouseOut() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。