您现在的位置是:首页 > 编程 > 

小程序 手指拖动切换下一张

2025-07-25 11:30:00
效果图: index.wxml: <view class=mask-movable> <image style=position:absolute;z-index:-1;height: 600rpx; width: 492rpx; mode= scaleToFill sr

效果图:

index.wxml:

<view class=mask-movable>
  <image style=position:absolute;z-index:-1;height: 600rpx; width: 492rpx; mode=	scaleToFill	 src=	{{img2}}	></image> 
  <movable-area wx:if={{hiddenimg}} style=height: 160vh; width: 260vw; background: transparent;>
    <movable-view style=height: 600rpx; width: 492rpx;background: transparent; x={{x}} y={{y}} direction=all bindchange=moveimg>
    <image bindtouchend=touchendimg bindtouchcancel=	touchendimg	  style=width:100%;height:100%; mode=	scaleToFill	 src=	{{img1}}	></image>
    </movable-view>
  </movable-area>
</view>

index.wxss

page{
  width:100%;
  height:100%;
  overflow:hidden;
}
.mask-movable{
  width: 492rpx;
  height: 600rpx;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%)
}

index.js

var prex = 0;
ct app = getApp()
Page({
  data: {
    img1: http://img5.imgtn.bdimg/it/u=1668080,562422762&fm=26&gp=0.jpg,
    img2: http://img4.imgtn.bdimg/it/u=65808774,1028297051&fm=26&gp=0.jpg,
    x: 0,
    y: 0,
    hiddenimg: true
  },
  moveimg: function (e) {
    var that = this;
    prex = e.detail.x;
    cole.log(	moveimg	, prex)
  },
  touchendimg: function (e) {
    cole.log(	touchendimg	, prex)
    var that = this;
    if (prex < -200 || prex > 200) {
      that.setData({
        hiddenimg: false,
      }, () => {
        setTimeout(function () {
          that.setData({
            hiddenimg: true,
            img1: that.data.img2
          })
        }, 00)
      })
    } else {
      setTimeout(function () {
        that.setData({
          x: 0,
          y: 0
        })
      }, 00)
    }
  },
})

 

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/biancheng/1115256.html

相关标签:无
上传时间: 2025-07-17 08:38:11
留言与评论(共有 16 条评论)
本站网友 海南手机之家
8分钟前 发表
-50%) } index.js var prex = 0; ct app = getApp() Page({ data
本站网友 藿香正气胶囊说明书
30分钟前 发表
})  
本站网友 成都娱乐会所
29分钟前 发表
() => { setTimeout(function () { that.setData({ hiddenimg
本站网友 pgp
16分钟前 发表
true }
本站网友 切口愈合等级
28分钟前 发表
260vw; background
本站网友 蒙牛董事长
13分钟前 发表
00) } }
本站网友 cwmp
23分钟前 发表
562422762&fm=26&gp=0.jpg
本站网友 丰润贴吧
15分钟前 发表
translate(-50%
本站网友 丰收年
30分钟前 发表
600rpx; width
本站网友 洫通激光治疗仪
23分钟前 发表
600rpx; width
本站网友 织发补发
9分钟前 发表
100%; mode= scaleToFill src= {{img1}} ></image> </movable-view> </movable-area> </view> index.wxss page{ width
本站网友 湘江世纪城租房
2分钟前 发表
img1
本站网友 蜂蜜的吃法
9分钟前 发表
moveimg
本站网友 高通公司
29分钟前 发表
50%; transform
本站网友 ddddddd
2分钟前 发表
hiddenimg