【问题标题】:Angular 9 ngx-image-cropper resize cropper with sliderAngular 9 ngx-image-cropper 使用滑块调整裁剪器大小
【发布时间】:2020-11-01 22:51:33
【问题描述】:

我在我的项目中使用ngx-image-cropper 库。我只想以 16/9 的纵横比裁剪图像,这没关系。我已将aspectRatio 设置为 16/9,并且裁剪器是矩形的。我还实现了mat-slider,它应该只改变图像裁剪器的宽度和高度,就像它使用裁剪器的拖动箭头来缩放它一样。是否有可能将调整裁剪器大小的 mat-slider 事件添加到通过拖动箭头更改裁剪器比例时它是如何工作的?我不想用垫子滑块缩放图像,而只是裁剪器。我在ngx-image-cropper 库中进行了搜索,但没有找到适合我需要的任何内容。感谢您的帮助!

图书馆链接:https://www.npmjs.com/package/ngx-image-cropper

    <div class="image-cropper-dimensions">
      <image-crop
        [imageFile]="data.file"
        [cropWidth]="sliderValue"
        [aspectRatio]="16 / 9"
        [isFileStrip]="true"
        [roundCropper]="data.isRoundedCropper"
        (onImageCropped)="onImageCropped($event)"
      >
      </image-crop>
    </div>
  </div>
  <div class="image-edit-container">
    <mat-slider
      [min]="SLIDER_MIN_VALUE"
      [color]="'primary'"
      [value]="sliderValue"
      [step]="SLIDER_STEP"
      (input)="onSliderChange($event)"
    >
    </mat-slider>

【问题讨论】:

    标签: angular cropper


    【解决方案1】:

    在我的应用程序中,我仅使用以下命令更改和高度: [maintainAspectRatio]="假"

    这是我的代码的一小部分:

    <image-cropper
      [imageChangedEvent]="imageChangedEvent"
      [imageURL]="imageUrl"
      [transform]="transform"
      [maintainAspectRatio]="false"
      [aspectRatio]="aspectRatio"
      [canvasRotation]="canvasRotation"
      (imageCropped)="imageCropped($event)"
    ></image-cropper>

    【讨论】:

    • 是的,在我的应用程序中,我需要调整它的大小,使其与维护AspectRatio 的工作方式完全一致,但使用滑块
    猜你喜欢
    • 2021-05-04
    • 1970-01-01
    • 2021-05-05
    • 2020-10-12
    • 2021-10-07
    • 1970-01-01
    • 2017-09-19
    • 2020-04-08
    • 1970-01-01
    相关资源
    最近更新 更多