1***@qq.com
1***@qq.com
  • 发布:2022-09-22 17:51
  • 更新:2022-09-23 10:43
  • 阅读:46

movable-view 缩放时页面显示错误

分类:uni-app

项目使用movable-view 缩放图片,在一定概率下缩放图片会留白,经排查是因为在缩放时 ,单纯使用定时器setTransfrom,会导致缩放时赋值 错误

此问题安卓 ios 必现

 <movable-area id="mapArea" style="width: 100%; height: 100%">  
      <movable-view  
        ref="mapView"  
        direction="all"  
        :x="mapX"  
        :y="mapY"  
        :scale="true"  
        :scale-value="mapScale"  
        :scale-min="mapScaleMin"  
        :scale-max="mapScaleMax"  
        style="position: relative; overflow: hidden"  
        :style="mapStyle"  
        @change="onchange"  
        @scale="onscale"  
      >  
        <view :draggable="false">  
        //此处是内容  
        </view>  
      </movable-view>  
    </movable-area>
2022-09-22 17:51 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com (作者)

附件如下

1***@qq.com

1***@qq.com (作者)

<template>  
    <movable-area id="mapArea" style="width: 100%; height: 100%;background-color: white;position: absolute;left: 0;top: 0;right: 0;bottom: 0;z-index: 9999999;">  
        <movable-view  
            ref="mapView"  
            direction="all"  
            :x="mapX"  
            :y="mapY"  
            :scale="true"  
            :scale-value="mapScale"  
            :scale-min="mapScaleMin"  
            :scale-max="mapScaleMax"  
            style="position: relative; overflow: hidden"  
            :style="mapStyle"  
            @change="onchange"  
            @scale="onscale"  
        >  
            <view :style="rootStyle" :draggable="false" @tap="tap2">  
                <image src="https://ss.dev.yiyiny.com/cloudFarm/2022/09/01/00tdftpi7l5ucgpo.jpeg" style="width: 100vw;height: 100vh;"></image>  
            </view>  
        </movable-view>  
    </movable-area>  
</template>  

<script>  
export default {  
    data() {  
        return {  
            oldScale:0,  
            mapX: 0,  
            mapY: 0,  
            mapScale: 1.2,  
            mapScaleMin: 1,  
            mapScaleMax: 2,  
            viewScale: 1,  
            mapStyle: 'width:100vw;height:100vh;',  
            rootStyle: '{width:100vw;height:100vh;transform-origin:0 0;transform:scale(0) translateZ(0)}',  
            // #ifdef MP-WEIXIN  
            root: undefined, // 微信小程序插槽兼容  
            // #endif  
            bg: false,  
            bgStyle: '',  
            bgStatus: {  
                bgScale: 1,  
                bgX: 0,  
                bgY: 0,  
                mapX: 0,  
                mapY: 0,  
                mapScale: 1  
            }  
        };  
    },  
    methods: {  
        tap2() {  
            this.$nextTick(function() {  
                this.mapScale = this.oldScale;  
            });  
        },  
        onChange: function(e) {  
            this.mapX = e.detail.x;  
            this.mapX = e.detail.y;  
        },  
        onScale: function(e) {  
            this.oldScale = e.detail.scale;  
        }  
    }  
};  
</script>  

<style>  

</style>  

要回复问题请先登录注册