pinchzoom 官网 http://manuelstofer.github.io/pinchzoom/


PortraitClip.css

.pinch-page{
    position:fixed;
    top:0;
    bottom:0;
    left:0;
    right:0;
    display:none;
    width:100%;
    height:100%;
    background-color:#333;
    z-index:9;

}
.pinch-page .top-mask,
.pinch-page .bottom-mask{
    position:absolute;
    left:0;
    top:0;
    right:0;
    display:block;
    background-color:rgba(0,0,0,0.6);
    z-index: 99;
}

.pinch-page .bottom-mask{
    top:auto;
    bottom:0;
}

.pinch-page .pinch-zoom-container{
    position:absolute!important;
    left:0;
    top:0;
    bottom:0;
    right:0;
    margin:auto;
    overflow: visible!important;
    z-index: 9;
    box-sizing: border-box;
}

.pinch-page .pinch-zoom-container:before{
    content:"";
    position:absolute;
    top:0;
    bottom:0;
    left:0;
    right:0;
    display:block;
    width:100%;
    height:100%;
    z-index:999;
    border:1px solid #fff;
    box-sizing: border-box;
}

.pinch-page .pinch-zoom{
}

.pinch-page .pinch-zoom-p_w_picpath{
    display:block;
    width:100%;
    height:320px;
    background: no-repeat center center;
    background-size:contain;
}

.pinch-page .operation-bar{
    position:absolute;
    left:0;
    right:0;
    bottom:0;
    display:block;
    height:60px;
    z-index: 999;
    background-color:rgba(51,51,51,0.6);
}
.pinch-page .operation-bar .cancel-btn{
    position:absolute;
    top:0;
    bottom:0;
    left:0;
    display:block;
    height:60px;
    line-height: 60px;
    font-size:16px;
    color:#fff;
    padding:0 20px;
}
.pinch-page .operation-bar .save-btn{
    position:absolute;
    top:0;
    bottom:0;
    right:0;
    display:block;
    height:60px;
    line-height: 60px;
    font-size:16px;
    color:#fff;
    padding:0 20px;
}

PortraitClip.js

(function($){
    /* ======================================== 页面渲染 ======================================== */
    /* ======================================== 不可变字段 ======================================== */
    var initialized = false; // 是否初始化
    var container = null;
    var clientWidth = $(window).width();
    var clientHeight = $(window).height();
    var pinchZoomImageWidth = clientWidth;
    var pinchZoomImageHeight = clientWidth;
    var maskHeight = (clientHeight-clientWidth)/2;
    var pinchZoom = null; // pinchZoom 对象

    /* ======================================== 可变字段 ======================================== */
    var p_w_picpathWidth = 0;
    var p_w_picpathHeight = 0;
    var xOffset = 0;
    var yOffset = 0;
    var originScale = 0;
    var p_w_picpath = null;
    var callback = null; // 加载完之后的回调



    // 构建DOM
    function render(){
        var html =  "                                                           "+
                    "                                                        "+
                    "                                                          "+
                    "     
                                        "+                     "