mcropper
要在移动端实现上传头像,本来采用
cropperjs
,开发完在手机上一跑,哭了。百度之,试用了一下AlloyCrop
,流畅但是可定制性不强,遂改源码。改着改着就面目全非了,那就尝试发布第一款npm包吧。
Features
- 只支持移动端
- 裁剪框大小自适应
- 初始化时图片有一边尺寸与裁剪框相等,另一边大于或等于裁剪框且居中
- 缩放图片时,双指中点对应图片的位置会跟随双指中点移动
- 无论移动或缩放,裁剪框始终包含在图片内
Getting started
/** * 图片加载完毕后的回调 * @callback ReadyCallback * @param */
Example
cropperContainer '/picture.png' { cropBtn { previewImgsrc = cropper previewImgstyledisplay = 'block' cropperContainerstyledisplay = 'none' cropBtn cropper }}
Preview
Demo
https://dgmpk.github.io/mcropper/
Dependencies
License
This content is released under the MIT License.