JCrop, how to clear all the div width/height markup?

前端 未结 2 1530
予麋鹿
予麋鹿 2021-01-13 07:48

I have a profile picture system which allows image cropping using jCrop. I\'ve noticed if the user goes through the process a few times, the crop dimensions are not calculat

相关标签:
2条回答
  • 2021-01-13 08:12

    I had a similar issue with an old version of jCrop and created a custom destroy function. Here is the gist of it:

    function crop_reset()
      {
      //Reset coordinates of thumbnail preview container
      $('#crop_preview').data("coords.x", 0);
      $('#crop_preview').data("coords.y", 0);
      $('#crop_preview').data("coords.w", 0);
      $('#crop_preview').data("coords.h", 0);
    
      //Reset src of jcrop img and copies bound to page specific full size and preview divs
      $("#crop, #crop_preview, .jcrop-holder img").attr("src", ""); 
      }
    
    function crop_start()
      {
      //Initialize and remove previous jCrop containers using load event callback
      $('#crop').Jcrop({
      onChange: showPreview,
      onSelect: showPreview,
      onLoad: hidePreview,
      aspectRatio: 1,
      setSelect: [0, 0, 50, 50],
      minSize: [50, 50],
      allowResize: false,
      allowMove: true
      },function(){$(".jcrop-holder").not(":last").remove();});
    
    
      //Remove previous jCrop containers using timer if callback is not supported
      /*
      window.setTimeout(function noblank(){
        $(".jcrop-holder").not(":last").remove();
        }, 1000);
      */
      }
    
    0 讨论(0)
  • 2021-01-13 08:24

    Making some huge assumptions about your situation, I've decided that you might try something like this: ​$(function(){$(​'.jcrop-holder').removeAttr("style");​​​​​​​​​});​​​​​

    If that's not what you need, you oughtta give us some more info!

    0 讨论(0)
提交回复
热议问题