Make Jcrop tracker not rotate when cropping a rotated image

前端 未结 5 1109
甜味超标
甜味超标 2020-12-19 03:56

I\'m trying to crop an image using Jcrop, but when I use jqueryrotate on the image, something weird happens.

I rotate the image 90 degress then I activate the JCrop,

5条回答
  •  时光说笑
    2020-12-19 04:28

    I used Dan's approach as a jumping off point but I don't have enough reputation to leave a comment on Dan Baker's answer so I'm submitting another answer. His mouseAbs function didn't work for me at all, I modified it as follows:

    function mouseAbs(e) 
    {
      switch (options.rotate) {
          case 90:
            return [(e.pageY - docOffset[1]), -(e.pageX - docOffset[0])];
          case 180:
            return [-(e.pageX - docOffset[0]), -(e.pageY - docOffset[1])];
          case 270:
            return [-(e.pageY - docOffset[1]), (e.pageX - docOffset[0])];
          default:
            return [(e.pageX - docOffset[0]), (e.pageY - docOffset[1])];
          }
    }
    

    Everything else was the same. Passed in the current rotation to the Jcrop object when it was initialized and I applied Dan's rotation css class to the .jcrop-holder element.

提交回复
热议问题