当前位置:网站首页>Achieve animation effect through event binding
Achieve animation effect through event binding
2022-07-04 17:48:00 【richest_ qi】
List of articles
Antecedents feed
The types of events involved in this example are :
touchstart, Finger touch action Start Trigger when .touchmove, After touching the fingers Move Trigger when .touchend, Finger touch action end Trigger when .
Event triggered , The event handler function will receive an event object , The attributes contained in the event object vary slightly depending on the type of event , among , The attributes of rain and dew are :
type, Event type .timeStamp, Time stamp when the event was generated .target, It's an object , Contains the following properties :id, Of the event source component id.dataset, On the event source component by data- A collection of custom properties at the beginning .
currentTarget, It's an object , Contains the following properties :id, Of the current component id.dataset, The current component consists of data- A collection of custom properties at the beginning .
mark, Event marker data .
In addition to the above basic attributes ,TouchEvent The event object of also contains the following properties :
touches, A collection of touch point information currently on the screen .touchesIs an array , Each array element is a Touch object , Indicates the touch point currently on the screen .Touch Object contains the following properties :identifier, value type , Is the identifier of the touch point .pageX, Horizontal distance from the upper left corner of the document .pageY, The vertical distance from the upper left corner of the document .clientX, The horizontal distance from the upper left corner of the visible area of the page .clientY, The vertical distance from the upper left corner of the visible area of the page .
changedTouches, Array of currently changing touchpoint information .
Applet project
The main files involved in the code are :
- app.json
- pages/index/index.wxml
- pages/index/index.wxss
- pages/index/index.js

app.json
{
"pages": [
"pages/index/index"
],
"window": {
"navigationBarBackgroundColor": "#971a22",
"navigationBarTitleText": " home page ",
"navigationBarTextStyle": "white"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
pages/index/index.wxml
<view class="indexContainer">
<view class="header"></view>
<view class="content" bindtouchstart="handleTouchStart" bindtouchmove="handleTouchMove" bindtouchend="handleTouchEnd" style="transform: translateY({
{
moveDistance}}rpx);transition: {
{
transitionSettings}};" >
<image src="/static/images/arc.png"></image>
</view>
</view>
pages/index/index.wxss
.indexContainer{
padding: 0 20rpx;
}
.header{
margin-top: 10rpx;
background: lightskyblue;
height: 300rpx;
border-radius: 10rpx;
}
.content{
margin-top: -100rpx;
height: 600rpx;
background: #f7f7f7;
border-bottom-right-radius: 10rpx;
border-bottom-left-radius: 10rpx;
position: relative;
}
.content image{
position: absolute;
top: -40rpx;
width: 100%;
height: 40rpx;
}
pages/index/index.js
let startY = 0;
let endY = 0;
let distance = 0;
let MIN_DIS = 0;
let MAX_DIS = 80
Page({
data:{
moveDistance:0,
transitionSettings:"none"
},
handleTouchStart(e){
// console.log("touch start");
startY = e.touches[0].clientY;
this.setData({
transitionSettings:"none"
})
},
handleTouchMove(e){
// console.log("touch move");
endY = e.touches[0].clientY;
distance = endY - startY;
if(distance < MIN_DIS) return;
if(distance > MAX_DIS) distance = MAX_DIS;
this.setData({
moveDistance:distance
})
},
handleTouchEnd(){
// console.log("touch end");
this.setData({
moveDistance:0,
transitionSettings:"transform .5s linear"
})
}
})
Related links
边栏推荐
- 整理混乱的头文件,我用include what you use
- DataKit——真正的统一可观测性 Agent
- 内核中时间相关的知识介绍
- [proteus simulation] printf debugging output example based on VSM serial port
- 超大规模数仓集群在大型商业银行的落地实践
- 【Proteus仿真】基于VSM 串口printf调试输出示例
- 通过事件绑定实现动画效果
- Superscalar processor design yaoyongbin Chapter 7 register rename excerpt
- Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
- NFT流动性市场安全问题频发—NFT交易平台Quixotic被黑事件分析
猜你喜欢
![[HCIA continuous update] overview of WLAN workflow](/img/0a/b3986307589a9f7379fe1dd707b9f8.png)
[HCIA continuous update] overview of WLAN workflow

Superscalar processor design yaoyongbin Chapter 7 register rename excerpt

Hidden corners of coder Edition: five things that developers hate most

Mathematical analysis_ Notes_ Chapter 7: differential calculus of multivariate functions

【华为HCIA持续更新】SDN与FVC

La 18e Conférence internationale de l'IET sur le transport d'électricité en courant alternatif et en courant continu (acdc2022) s'est tenue avec succès en ligne.

Using win10 scheduling task program to automatically run jar package at fixed time

就在今天丨汇丰4位专家齐聚,共讨银行核心系统改造、迁移、重构难题
《吐血整理》保姆级系列教程-玩转Fiddler抓包教程(2)-初识Fiddler让你理性认识一下

数学分析_笔记_第7章:多元函数的微分学
随机推荐
Superscalar processor design yaoyongbin Chapter 7 register rename excerpt
Analysis of I2C adapter driver of s5pv210 chip (i2c-s3c2410. C)
R语言plotly可视化:plotly可视化多分类变量小提琴图(multiple variable violin plot in R with plotly)
Oppo Xiaobu launched Obert, a large pre training model, and promoted to the top of kgclue
超标量处理器设计 姚永斌 第5章 指令集体系 摘录
To sort out messy header files, I use include what you use
新享科技发布小程序UniPro小优 满足客户移动办公场景
我写了一份初学者的学习实践教程!
整理混乱的头文件,我用include what you use
R language plot visualization: plot visualization of multiple variable violin plot in R with plot
Perfectly integrated into win11 style, Microsoft's new onedrive client is the first to see
Vb无法访问数据库stocks
Is it safe for Bank of China Securities to open an account online?
Superscalar processor design yaoyongbin Chapter 5 instruction set excerpt
About the pit of firewall opening 8848 when Nacos is started
大规模服务异常日志检索
Difference between redis' memory obsolescence strategy and expiration deletion strategy
leetcode:421. The maximum XOR value of two numbers in the array
长城证券开户安全吗 证券账户怎么开通
[HCIA continuous update] overview of WLAN workflow