Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎么限制元素的移动方向? #124

Closed
wumingluren opened this issue Apr 13, 2024 · 5 comments
Closed

怎么限制元素的移动方向? #124

wumingluren opened this issue Apr 13, 2024 · 5 comments

Comments

@wumingluren
Copy link

比如只能横向移动,垂直移动,不让元素自由拖动。

@wumingluren
Copy link
Author

看了下Fabric有这个配置
lockVertical: true, // 锁定垂直移动
lockHorizontal: false // 允许水平移动

@leaferjs
Copy link
Owner

目前是通过shift快捷键自动控制的, 后面可以增加下这个配置。 如果你想自己实现,可以通过PropertyEvent检测x,y变化,然后进行修正

https://www.leaferjs.com/ui/guide/event/basic/Property.html

@wumingluren
Copy link
Author

wumingluren commented Apr 13, 2024

目前是通过shift快捷键自动控制的, 后面可以增加下这个配置。 如果你想自己实现,可以通过PropertyEvent检测x,y变化,然后进行修正

https://www.leaferjs.com/ui/guide/event/basic/Property.html

https://www.leaferjs.com/ui/guide/event/ui/Drag.html#%E6%89%8B%E5%8A%A8%E6%8B%96%E6%8B%BD%E5%85%83%E7%B4%A0

使用这个手动拖拽元素搞定了,只能绑定在具体元素上,绑定在app上就无效。

@leaferjs
Copy link
Owner

监听全局的,可以绑定在app.tree上

@leaferjs
Copy link
Owner

图片编辑器已增加 config.lockMove 配置,可锁定在 x 或 y 轴移动

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants