RotateEvent
旋转事件,一般用于 视口交互 中旋转 视图 或 元素。
- 移动端: 双指旋转
- 触摸板: 双指旋转(仅 Safari 支持)
事件名称
RotateEvent.START
开始旋转事件
rotate.start
RotateEvent.ROTATE
旋转事件
rotate
RotateEvent.END
结束旋转事件
rotate.end
关键属性
rotation: number
此次旋转事件改变的角度
示例
ts
// #监听旋转交互事件
import { Leafer, Rect, RotateEvent, LeafHelper } from 'leafer-ui'
import '@leafer-in/viewport' // 导入视口插件 //
const leafer = new Leafer({
view: window,
type: 'custom'
})
const rect = new Rect({ x: 100, y: 100, fill: '#32cd79', draggable: true })
leafer.add(rect)
leafer.on(RotateEvent.ROTATE, function (e: RotateEvent) {
const center = { x: e.x, y: e.y }
LeafHelper.rotateOfWorld(leafer, center, e.rotation)
})
js
// #监听旋转交互事件
import { Leafer, Rect, RotateEvent, LeafHelper } from 'leafer-ui'
import '@leafer-in/viewport' // 导入视口插件 //
const leafer = new Leafer({
view: window,
type: 'custom'
})
const rect = new Rect({ x: 100, y: 100, fill: '#32cd79', draggable: true })
leafer.add(rect)
leafer.on(RotateEvent.ROTATE, function (e) {
const center = { x: e.x, y: e.y }
LeafHelper.rotateOfWorld(leafer, center, e.rotation)
})