joystick() 操纵杆#
基于nipple.js创建操纵杆。
on_start: 当用户触摸操纵杆时的回调on_move: 当用户移动操纵杆时的回调on_end: 用户释放操纵杆时的回调throttle: 移动事件的 Throttleinterval(以秒为单位)(默认值:0.05)options: 像color这样的参数应该传递给底层的nipple.js库
from nicegui import ui
ui.joystick(color='blue', size=50,
on_move=lambda e: coordinates.set_text(f"{e.x:.3f}, {e.y:.3f}"),
on_end=lambda _: coordinates.set_text('0, 0'))
coordinates = ui.label('0, 0')
# ui.run()