语法
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 |
浏览器兼容性
加载中…