• 手机版

    扫码体验手机版

  • 微信公众号

    扫码关注公众号

国内首家协议开发

软芯音视解码保护平台

在线
客服

发布
需求

在线
聊天

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

请问大神下面代码中的加粗部分是啥意思。

define(['jquery'],function($){
   function Rotate(){
        this.cfg = {
            rotateBox : null,
            handle : null
        };
    }

    Rotate.prototype = {
        convertAngle : function(a){
            return a/Math.PI*180
        },

        onMove : function(){
            //console.log(this);
            this.angle2 = this.convertAngle(Math.atan2(this.oy - this.my, this.mx - this.ox));      //计算鼠标和元素中心连线 与 水平线夹角
            this.angle = this.angle1 - this.angle2 + this.oldDeg;                                        //计算旋转角度
            this.rotateBox.css({
                transform : "rotate(" + this.angle + "deg)"
            });
        },


        init : function(cfg){
            //console.log(this);
            $.extend(this.cfg,cfg,{});
            this.rotateBox = this.cfg.rotateBox;
            if(this.cfg.handle){
                this.handle = this.cfg.handle;
            }else{

            }
            this.handle.mousedown(function(e){
                var e = window.event || e;
                this.ox = this.rotateBox.width()/2+this.rotateBox.offset().left;    //计算元素中心坐标
                this.oy = this.rotateBox.height()/2+this.rotateBox.offset().top;
                this.x1 = this.handle.offset().left+this.handle.width()/2;          //计算手柄坐标
                this.y1 = this.handle.offset().top+this.handle.height()/2;
                this.angle1 = this.convertAngle(Math.atan2(this.oy-this.y1,this.x1-this.ox));//计算元素中心和手柄连线 与 水平线夹角
                if(this.rotateBox[0].style.transform){
                    this.oldDeg = Number(this.rotateBox[0].style.transform.slice(7,-4)) % 360;      //获取元素初始角度
                }else{
                    this.oldDeg = 0;
                }

                this.moving = setInterval(this.onMove.bind(this),40);
            }.bind(this));

            document.addEventListener('mousemove',function(e){
                var e = window.event || e;
                this.mx = e.pageX;                  //获取移动时鼠标位置坐标
                this.my = e.pageY;
            }.bind(this),false);

            document.addEventListener('mouseup',function() {
                clearInterval(this.moving);
            }.bind(this),false);
        }
    };

   return {
        Rotate : Rotate
    }

});

免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。

版权声明:作者保留权利,不代表天盟立场。

使用道具 举报

全部参与1

返回Rotate对象

使用道具 举报

发新帖

发布任务需求已有1031168位用户正在使用天盟网服务

发布分类: *
任务预算: *
需求内容: *
手机号码: *
任务商家报价为
  • 预算价 :
  • 成交价 :
  • 完工期 :
  • 质保期 :

* 最终任务项目以服务商报价、双方协商为准!