Home  >  Article  >  WeChat Applet  >  How to implement mouse drag effect in WeChat applet

How to implement mouse drag effect in WeChat applet

小云云
小云云Original
2018-01-05 10:44:585802browse

This article mainly introduces the implementation of mouse dragging effect in WeChat applet, involving implementation techniques related to event binding of WeChat applet and dynamic operation of element attributes. Friends in need can refer to it, and I hope to share it with everyone.

1. Effect display

2. Key code

index.wxml file


<view class="view"
 style="left:{{left}}px;top:{{top}}px;"
 bindtouchmove="viewTouchMove"
 >使用鼠标拖动我</view>

index.js file


Page({
  data:{
    left:&#39;&#39;,
    top:&#39;&#39;
  },
  viewTouchMove:function(e){
    this.setData({
      left:e.touches[0].clientX-60,
      top:e.touches[0].clientY-60
    })
  }
})

Related recommendations:

js implements mouse drag function

css3 transform and native js implementation of mouse dragging 3D cube rotation example introduction

##jquery implementation of mouse dragging image effect example code_jquery

The above is the detailed content of How to implement mouse drag effect in WeChat applet. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn