放大和放大在Angular中缩小对ngx-image-cropper不起作用 [英] Zoom in & zoom out in Angular not working for ngx-image-cropper

查看:60
本文介绍了放大和放大在Angular中缩小对ngx-image-cropper不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试放大&缩小ngx-image-cropper.我没有收到任何错误,但是当我单击按钮zoomOut或ZoomIn时不起作用.

I am trying for Zoom in & Zoom out from ngx-image-cropper. I am not getting any error but when I click the button zoomOut or ZoomIn it's not working.

我在做什么错了?

我的TS代码

  zoomOut() {
    this.scale -= .1;
    this.transform = {
        ...this.transform,
        scale: this.scale
    };
}

zoomIn() {
    this.scale += .1;
    this.transform = {
        ...this.transform,
        scale: this.scale
    };
}

我的HTML代码

       <button class="btn zoomIn" (click)="zoomIn()" tooltip="Zoom In" data-toggle="tooltip" data-placement="top" title="Zoom In"></button>
       <button class="btn zoomOut" (click)="zoomOut()" tooltip="Zoom Out" data-toggle="tooltip" data-placement="top" title="Zoom Out"></button>

推荐答案

export class AppComponent {  
  zoom:boolean=false;
  zoomOut(){
    this.zoom=false;
  }
  zoomIn(){
    
    this.zoom=true;
  }
  getheight(){
    if(this.zoom==true){
      return '500px';
      //return your desiderd value in pixel or in percentage
    }
    else{
      return '200px';
      }
  }

}

button{
    padding: 8px;
}
#test-zoom{
    height: 500px;
    width: 100%;
    position: relative;
    background: red;
}
.zoom-card{
    height: 500px;
    width: 90%;
    position: relative;
    margin: auto;
    background: lime;
}

.test-image{
    width: auto;
}

<section id="test-zoom">
  <div class="zoom-card">
    <img [ngStyle]="{'height':getheight()}" width="auto" class="test-image" src="https://www.netcetra.com/images/howto_images/photoshop-logo.jpg">
    <br>
    <button (click)="zoomIn()" >Zoom In</button>
    <button (click)="zoomOut()" >Zoom Out</button>

  </div>
</section>

使用此代码并将其粘贴到app.component.ts,CSS和HTML文件中.

Use this code and paste it into app.component.ts, CSS, and HTML files.

这篇关于放大和放大在Angular中缩小对ngx-image-cropper不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆