Skip to content

应用配置

基础     视口类型     画布     点按     多点     触屏     滚轮     平移视图     缩放视图

触摸事件相关配置, 应用运行中修改 app.config.touch 立即生效。

注意事项

App 结构 下只能设置在 App 的 config 上。

关键属性

touch.preventDefault: boolean | 'auto'

是否阻止移动端默认触摸屏滑动页面事件,默认为 'auto'。

设置 'auto', draggable / editable / 监听 DragEvent.DRAG 的元素仍可单独拖拽,其他地方拖拽将会滑动页面。

设置 true, 所有地方拖拽将不会滑动页面,当为应用添加 缩放平移视图 功能时自动使用此配置。

设置 false, 所有地方拖拽将会滑动页面。

示例

阻止移动端默认滑动页面事件

ts
// #应用配置 - 阻止移动端默认滑动页面事件 [Leafer]
import { Leafer, Rect } from 'leafer-ui'

const leafer = new Leafer({
    view: window,
    touch: { preventDefault: true }
})

leafer.add(Rect.one({ fill: '#32cd79' }, 100, 100))
ts
// #应用配置 - 阻止移动端默认滑动页面事件 [App]
import { App, Rect } from 'leafer-ui'

const app = new App({
    view: window,
    tree: { touch: { preventDefault: true } }
})

app.tree.add(Rect.one({ fill: '#32cd79' }, 100, 100))

Released under the MIT License.