Giter Club home page Giter Club logo

alipaycrop's Introduction

修改 wx-plugin/image-cropper 微信小程序裁剪,支持支付宝小程序

  • 去除了裁剪动画,动画在支付宝小程序会有卡顿
  • 修改了组件属性和方法 适用于支付宝小程序
  • 支付宝小程序使用了 ref来获取组件,开发工具选项勾选 启用component2编译
  • 注意支付宝小程序里的 canvas 组件id 支付宝<canvas id='image-cropper'> 和微信的区别微信<canvas canvas-id='image-cropper'>
  • 支付宝小程序旋转或者移动canvas的画布后需要还原 this.data.ctx.save(); this.data.ctx.restore();

axml

<image-cropper a:if="{{show}}" ref="imagecropper" id="image-cropper" limit_move="{{true}}" disable_rotate="{{true}}" width="{{width}}" height="{{height}}" imgSrc="{{src}}" bindload="cropperload" onLoadimage="loadimage" onClickcut="clickcut"></image-cropper>

js

data:{
    src: '',
    width: 250, //宽度
    height: 250, //高度
}

imagecropper(ref) {
    // 存储自定义组件实例,方便以后调用
    this.cropper = ref;
},

imgCropp() {
    console.log('imgCropp');
    this.cropper.getImg(obj => {
        console.log(obj);
        my.previewImage({
            urls: [obj.url] // 需要预览的图片http链接列表
        });
    });
},

loadimage(e) {
    console.log('图片加载完成', e.detail);
    my.hideLoading();
    //重置图片角度、缩放、位置
    this.cropper.imgReset();
},

json

{
    "usingComponents": {
    "image-cropper": "./image-cropper/image-cropper"
  },
}

alipaycrop's People

Contributors

yybt avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.