語法
js
reset()
引數
無。
返回值
如果效果重置成功,則 Promise 解析為 "complete";如果效果被停止或被另一個效果替換,則 Promise 解析為 "preempted"。
Promise 可能會因以下異常型別而拒絕:
InvalidStateErrorDOMException-
如果當前文件未啟用或處於隱藏狀態,則 Promise 將因
InvalidStateError而拒絕。
示例
js
const gamepad = navigator.getGamepads()[0];
setTimeout(() => {
gamepad.vibrationActuator.reset();
}, 150);
gamepad.vibrationActuator
.playEffect("dual-rumble", {
startDelay: 0,
duration: 200,
weakMagnitude: 1.0,
strongMagnitude: 1.0,
})
.then((result) => console.log(result));
// Should log "preempted" because reset() will run before the effect ends
規範
| 規範 |
|---|
| Gamepad # dom-gamepadhapticactuator-reset |
瀏覽器相容性
載入中…