最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - not able to see the preview for cropper js - Stack Overflow

programmeradmin3浏览0评论

I have created an application using cropper.js for cropping an images, the application is working and the image is cropping but I am not able to see the preview, my preview div is not populating anything correctly while cropping. My code is as given below

Can anyone please tell me some solution for this

Plunker

script

 var $image = $('.img-container > img'),
    $dataRotate = $('#dataRotate'),
    options = {
       modal: true,
       guides: true,
       autoCrop: false,
       dragCrop: true,
       movable: true,
       resizable: true,
       zoomable: false,
       touchDragZoom: false,
       mouseWheelZoom: false,
       preview: '.preview',
      crop: function (data) {
        $dataRotate.val(Math.round(data.rotate));
      }
    };

I have created an application using cropper.js for cropping an images, the application is working and the image is cropping but I am not able to see the preview, my preview div is not populating anything correctly while cropping. My code is as given below

Can anyone please tell me some solution for this

Plunker

script

 var $image = $('.img-container > img'),
    $dataRotate = $('#dataRotate'),
    options = {
       modal: true,
       guides: true,
       autoCrop: false,
       dragCrop: true,
       movable: true,
       resizable: true,
       zoomable: false,
       touchDragZoom: false,
       mouseWheelZoom: false,
       preview: '.preview',
      crop: function (data) {
        $dataRotate.val(Math.round(data.rotate));
      }
    };
Share Improve this question edited Apr 22, 2015 at 9:53 Alex Man asked Apr 22, 2015 at 5:58 Alex ManAlex Man 4,88619 gold badges104 silver badges188 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 14

You need to set the size of the .preview element with css. Also set the overflow to hidden, e.g.

.preview {
  overflow: hidden;
  width: 50px; 
  height: 50px;
}

Also forked your plunk and your updated plunk.

发布评论

评论列表(0)

  1. 暂无评论