简体   繁体   English

Ionic上的图像缩放问题

[英]Image zooming issue on Ionic

I am trying to implement image zooming for image in Ionic app. 我正在尝试在Ionic应用程序中实现图像的图像缩放。 It has been implemented here 它已经在这里实现

and works flawlessly on the original project created with Ionic V 1.0.0 but doesn't seem to work all that good in Ionic V 1.3.0. 并且可以在使用Ionic V 1.0.0创建的原始项目上完美运行,但在Ionic V 1.3.0中似乎无法很好地工作。

On V 1.1.0 this 在V 1.1.0上

($ionicScrollDelegate.$getByHandle('scrollHandle' + slide).getScrollPosition()) ($ ionicScrollDelegate。$ getByHandle('scrollHandle'+ slide).getScrollPosition())

logs a json like this 记录这样的json

{"left":0,"top":0,"zoom":1} {“左”:0,“顶部”:0,“缩放”:1}

But in V 1.3.0 it logs it as 但是在V 1.3.0中,它记录为

undefined 未定义

Also on chrome it shows warning like this: 同样在chrome上,它显示如下警告:

Delegate for handle "scrollHandle0" could not find a corresponding element with delegate-handle="scrollHandle0"! 句柄“ scrollHandle0”的委托找不到带有委托委托“ scrollHandle0”的对应元素! getScrollPosition() was not called! getScrollPosition()没有被调用! Possible cause: If you are calling getScrollPosition() immediately, and your element with delegate-handle="scrollHandle0" is a child of your controller, then your element may not be compiled yet. 可能的原因:如果立即调用getScrollPosition(),并且您的带有委托指针=“ scrollHandle0”的元素是控制器的子级,则该元素可能尚未编译。 Put a $timeout around your call to getScrollPosition() and try again. 在对getScrollPosition()的调用周围放置$ timeout,然后重试。

This is still working on devices (tested both on iOS and Android) but not smooth at all. 它仍然可以在设备上运行(在iOS和Android上均经过测试),但一点都不流畅。 It is very laggy. 太懒了。 Any thoughts or workarounds? 有什么想法或解决方法吗?

So the issue had nothing to do with Ionic version which I realised after more debugging. 因此,该问题与经过更多调试后才意识到的Ionic版本无关。 It was due to 这是由于

delegate-handle="scrollHandle{{$index}}" proxy-handle =“ scrollHandle {{$ index}}”

In my usecase I was not using ng-repeat so was using 在我的用例中,我没有使用ng-repeat,所以使用了

delegate-handle="scrollHandle" proxy-handle =“ scrollHandle”

But this was not working and causing the above mentioned issues. 但这不起作用,并导致上述问题。 So fix was to add 0 as index with it. 因此,解决方法是将0添加为索引。 In my case this solved it. 就我而言,这解决了它。

delegate-handle="scrollHandle0" proxy-handle =“ scrollHandle0”

In other cases use case may be different so but if using ng-repeat this would work 在其他情况下,用例可能会有所不同,所以如果使用ng-repeat可以

delegate-handle="scrollHandle{{$index}}" proxy-handle =“ scrollHandle {{$ index}}”

and if not this should do the trick 如果不是这样,应该可以解决问题

delegate-handle="scrollHandle0" proxy-handle =“ scrollHandle0”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM