gpt4 book ai didi

ionic2 - 如何在 ionic 滚动中缩放图像

转载 作者:行者123 更新时间:2023-12-03 17:42:05 26 4
gpt4 key购买 nike

我正在开发 Ionic2 应用程序。我想在 ion-scroll 中缩放图像。我该怎么做。

    <ion-scroll scrollX="true" scrollY="true" zoom=true>
<img src="https://aa.com/app/package_content/s78c_e4vt6/main_images/pg_114.jpg" />
</ion-scroll>

最佳答案

我可以通过为 tap 事件编写一小段代码来缩放 ion-scroll 中的图像。此代码在 android/ios ionic 2 中经过测试和工作。点击一次放大,再次点击缩小。对于 ios,只需在 ion-content 中添加 overflow scroll 即可平滑滚动。

.ts 页面:

  export class PageName {

constructor() {
}
public tap: number = 600;

tapEvent(e) {
if (this.tap != 700) {
this.tap = 700;
}
else
this.tap = 600;
}}

html:

 <ion-content style="background-image:url(assets/img/image1.PNG); white-space: nowrap; overflow: scroll; overflow-x:scroll; height: 100%">
<ion-scroll scrollX="true" scrollY="true" (tap)="tapEvent($event)" zoom="true" style="width:100%;height:100%;text-align:center;">
<div class="scroll-item" style=" width:100%; white-space: nowrap; overflow: scroll;">
<img [ngStyle]="{'width' : tap + 'px', 'min-width' : tap + 'px'}" alt="logo" src="assets/img/image2.PNG">
</div>
</ion-scroll> </ion-content>

关于ionic2 - 如何在 ionic 滚动中缩放图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43196990/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com