小程序的拖拽、缩放和旋转手势

本文介绍了如何在小程序中实现类似App的手势操作,包括拖拽、缩放和旋转功能。作者honey缘木鱼分享了wxml、wxss、js和json四个部分的实现代码,为小程序开发者提供了详细的实现步骤。
摘要由CSDN通过智能技术生成

在开发中,有时会遇到像App中的手势那样的效果,下面就仿照App实现了一下。

wxml部分:

<view class="touch-container">
 <view class="msg">{
  {msg}}</view>
 <image
 class="img"
 src="{
  {src}}"
 style="width: {
  {width}}rpx; height: {
  {height}}rpx; left: {
  {left}}rpx; top: {
  {top}}rpx; transform: translate(-50%, -50%) scale({
  { scale }}) rotate({
  { rotate }}deg);"
 bindload="bindload"
 catchtouchstart="touchstart"
 catchtouchmove="touchmove"
 catchtouchend="touchend"
 ></image>
</view>

 

wxss部分:

page {

  width: 100%;

  height: 100%;

  background: #ffffff;

}

.touch-container {

  width: 100%;

  height: 100%;

  padding-top: 0.1px;

}

.msg {

  width: 100%;

  height: 60rpx;

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值