onLoadCanvas : function()
{
+ console.log("ON LOAD CANVAS");
this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
setCanvasPosition : function()
{
+ console.log("SET CANVAS POSITION");
if(!this.canvasEl){
return;
}
onMouseDown : function(e)
{
+ console.log("ON MOUSE DOWN");
e.stopEvent();
this.dragable = true;
onMouseMove : function(e)
{
+ console.log ("ON MOUSE MOVE");
e.stopEvent();
if(!this.canvasLoaded){
var minX = Math.ceil(this.thumbEl.getLeft(true));
var minY = Math.ceil(this.thumbEl.getTop(true));
+
+ console.log("minX");
+ console.log(minX);
+ console.log("minY");
+ console.log(minY);
var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
+ console.log("maxX");
+ console.log(maxX);
+ console.log("maxY");
+ console.log(maxY);
+
+ if(minX < maxX && minY < maxY) {
+ return;
+ }
+
var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
x = x - this.mouseX;
y = y - this.mouseY;
+ console.log("MOVE LEFT / RIGHT");
+ console.log(x);
+ console.log("MOVE UP / DOWN");
+ console.log(y);
+
var bgX = Math.ceil(x + this.previewEl.getLeft(true));
var bgY = Math.ceil(y + this.previewEl.getTop(true));
+
+ console.log("bgX");
+ console.log(bgX);
+ console.log("bgY");
+ console.log(bgY);
- bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
- bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
+ bgX = (minX > bgX) ? minX : ((maxX < bgX) ? maxX : bgX);
+ bgY = (minY > bgY) ? minY : ((maxY < bgY) ? maxY : bgY);
this.previewEl.setLeft(bgX);
this.previewEl.setTop(bgY);
draw : function()
{
+ console.log("DRAW");
this.previewEl.dom.innerHTML = '';
var canvasEl = document.createElement("canvas");
var contextEl = canvasEl.getContext("2d");
+
+ console.log(this.getScaleLevel());
canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
setThumbBoxPosition : function()
{
+ console.log("SET THUMBBOX POSITION");
var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
baseRotateLevel : function()
{
+ console.log("BASE ROTATE LEVEL");
this.baseRotate = 1;
if(
baseScaleLevel : function()
{
+ console.log("BASE SCALE LEVEL");
var width, height;
if(this.isDocument){
}
}
-
+
+ if(this.imageEl.OriginWidth < this.minWidth || this.imageEl.OriginHeight < this.minHeight) {
+ this.baseScale = width / this.minWidth;
+ }
+ console.log(this.baseScale);
return;
},