[英]How to simulate mouse wheel on a canvas?
我對 canvas 元素進行了物理模擬,您可以使用鼠標滾輪在此 canvas 元素中放大和縮小。 我想以編程方式觸發鼠標滾輪。 是否可以在 canvas 元件上使用鼠標滾輪模擬用戶? 我沒有運氣創建一個新的 WheelEvent 並在 canvas 上調度它。
var wheelEvent = new WheelEvent( 'wheel', { deltaY: 120 } );
document.getElementById('canvas').dispatchEvent(wheelEvent);
您可以從 GitHub repo Canvas Zoom Example查看此示例
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.