jQuery头像左右动画旋转并支持裁剪

jQuery头像左右动画旋转并支持裁剪

分享一款左右旋转的头像插件,而且支持放大镜拖动图片剪切,并且生成两种不同尺寸的图片。

淘建站为您提供更多_其它特效_jQuery插件_旋转_头像,在此特别感谢您对我们的支持与厚爱!

查看演示

演示不了,点击反馈

加入收藏

下载 310 次

打赏作者

觉得不错,可打赏下作者

下载资源

免费共享

特别说明:本站资源来自网友发布分享,仅供学习与参考,请勿用于商业用途,若有侵权请联系删除(272966172@qq.com)。

头像旋转和裁剪html代码

<div class="portrait_left"> 
    <div id="picture">
        <img id="avatar" alt="请上传头像" src="images/Koala_cropped.jpg" />
    </div> 
    <form id="crop_form" method="post" action="."> 
        <!--通过生成尺寸和旋转角度 后台获取尺寸和旋转角度再进行裁剪--> 
        <input id="id_top" type="hidden" name="top" value="90" /> 
        <input id="id_left" type="hidden" name="left" value="61" /> 
        <input id="id_right" type="hidden" name="right" value="201" /> 
        <input id="id_bottom" type="hidden" name="bottom" value="200" /> 
        <input id="rotation" type="hidden" value="0" name="rotation" /> 
    </form> 
    <div class="portrait_revolve"> 
        <div class="revolve_left"></div> 
        <a href="javascript:;" class="revol_left_txt" onclick="avatarrotateleft();">向左旋转</a> 
        <a href="javascript:;" class="revol_right_txt" onclick="avatarrotateright();">向右旋转</a> 
        <div class="revolve_right"></div> 
    </div> 
    <div class="setup_but">
        <button class="baseinf_but1" onclick="submit_avatar();">确定</button>
    </div> 
</div> 
<div class="portrait_right"> 
    <p class="portrait_right_txt">您上传的头像会自动生成小尺寸头像,请注意小尺寸的头像是否清晰</p> 
    <div class="portrait_right_bottom"> 
        <div class="portrait1"> 
            <div id="img_big_preview" class="img_preview">
                <img id="avatar1" alt="头像预览" src="images/Koala_cropped.jpg" style="width:360px;height:360px;margin-left:-117px;margin-top:-44px;" />
            </div> 
            <p>大尺寸头像,180&times;180</p> 
        </div> 
    </div> 
    <div class="portrait2"> 
        <div id="img_small_preview" class="img_preview">
            <img id="avatar2" alt="预览" src="images/Koala_cropped.jpg" style="width: 98px; height: 98px; margin-left: -32px; margin-top: -12px;" />
        </div> 
        <p>中尺寸头像</p> 
        <p>50&times;50</p> 
    </div> 
</div>
$(document).ready(function() {
    function adjust(el, selection) {
        var scaleX = $(el).width() / (selection.width || 1);
        var scaleY = $(el).height() / (selection.width || 1);
        $(el + ' img').css({
            width: Math.round(scaleX * $('#avatar').width()) + 'px',
            height: Math.round(scaleY * $('#avatar').height()) + 'px',
            marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
            marginTop: '-' + Math.round(scaleY * selection.y1) + 'px'
        });
    }
    function preview(img, selection) {
        adjust('#img_small_preview', selection);
        adjust('#img_big_preview', selection);
    }
    $('img#avatar').imgAreaSelect({
        aspectRatio: "4:4",
        x1: 60,
        y1: 60,
        x2: 200,
        y2: 200,
        onSelectEnd: function(img, selection) {
            $('#id_top').val(selection.y1);
            $('#id_left').val(selection.x1);
            $('#id_right').val(selection.x2);
            $('#id_bottom').val(selection.y2);
        },
        onSelectChange: preview
    });
});



var value = 0;
function avatarrotateleft() {
    value -= 90;
    $('#avatar').rotate({animateTo: value});
    $('#avatar1').rotate({animateTo: value});
    $('#avatar2').rotate({animateTo: value});
}
function avatarrotateright() {
    value += 90;
    $('#avatar').rotate({animateTo: value});
    $('#avatar1').rotate({animateTo: value});
    $('#avatar2').rotate({animateTo: value});
}
function select_avatar() {
    $('#avatar_id').click();
}
function uploadavatar() {
    $('#avatar_form').submit();
}
function submit_avatar() {
    $('#rotation').val(value);
    alert('修改成功');
    $('#crop_form').submit();
}

声明:本资料由淘建站会员提供,如转载注明来源,资料来源淘建站免费素材库:https://www.taojz.cn/texiao/918.html
jQuery头像左右动画旋转并支持裁剪 希望对你有帮助,感谢您的支持!
  • 纯css3网状布局鼠标经过图片旋转特效

    纯css3网状布局鼠标经过图片旋转特效

  • 纯CSS3绘制哆啦A梦头像动画代码

    纯CSS3绘制哆啦A梦头像动画代码

  • 旋转的正方体css3制作3D立体效果

    旋转的正方体css3制作3D立体效果

  • css实现3D陀螺旋转

    css实现3D陀螺旋转

  • 纯css3 3D图片立方体旋转动画特效

    纯css3 3D图片立方体旋转动画特效

  • canvas制作旋转的万花筒

    canvas制作旋转的万花筒

  • html5 canvas文字标签云3D旋转动画特效

    html5 canvas文字标签云3D旋转动画特效

  • html5 canvas页面滚动背景图片旋转动画特效

    html5 canvas页面滚动背景图片旋转动画特效

  • css3实现旋转彩色光晕球体

    css3实现旋转彩色光晕球体

  • CSS3实现陀螺旋转特效

    CSS3实现陀螺旋转特效

  • 3D立体旋转美女_纯CSS3实现

    3D立体旋转美女_纯CSS3实现

  • css效果旋转3d图

    css效果旋转3d图

  • 留言(0)
    头像
     阿里云限量代金券,戳我领取
    1 2