-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresizer.min.js
1 lines (1 loc) · 1.48 KB
/
resizer.min.js
1
!function(e){let t=function(e,t,i,n,l){this.img_ele=null,this.x_cursor=0,this.y_cursor=0,this.x_img_ele=0,this.y_img_ele=0,this.init(e,t,i,n,l)};function i(e){this.img_ele=document.getElementById(e),this.img_ele.style.width="100%",this.img_ele.style.height="100%",this.img_ele.style.left=0,this.img_ele.style.top=0,this.img_ele=null}function n(e,t){this.img_ele=document.getElementById(e);let i=this.img_ele.getBoundingClientRect().width,n=this.img_ele.getBoundingClientRect().height;this.img_ele.style.width=i*t+"px",this.img_ele.style.height=n*t+"px",this.img_ele=null}function l(t){this.img_ele=document.getElementById(t),this.x_img_ele=e.event.clientX-this.img_ele.offsetLeft,this.y_img_ele=e.event.clientY-this.img_ele.offsetTop}function s(){this.img_ele=null}function m(){this.x_cursor=e.event.clientX,this.y_cursor=e.event.clientY,this.img_ele&&(this.img_ele.style.left=this.x_cursor-this.x_img_ele+"px",this.img_ele.style.top=e.event.clientY-this.y_img_ele+"px")}t.prototype={constructor:t,init:function(e,t,c,g,h){let o=this;c&&g&&h&&(document.getElementById(g).addEventListener("click",(function(){n.call(o,t,.25)})),document.getElementById(c).addEventListener("click",(function(){n.call(o,t,1.25)})),document.getElementById(h).addEventListener("click",(function(){i.call(o,t)}))),document.getElementById(t).addEventListener("mousedown",l.bind(o,t)),document.getElementById(e).addEventListener("mousemove",m.bind(o,t)),document.getElementById(e).addEventListener("mouseup",s.bind(o))}},e.Resizer=t}(window);