基于JS實(shí)現(xiàn)Android,iOS一個(gè)手勢(shì)動(dòng)畫效果
廢話不多說了,先給大家展示下效果圖:

這是iOS下的效果,android下完全一致。通過do_GestureView組件和do_Animation組件,deviceone能很容易實(shí)現(xiàn)復(fù)雜的跨平臺(tái)純?cè)鷦?dòng)畫效果,這個(gè)示例就是通過手勢(shì)控制圖片上下動(dòng)畫滑動(dòng)實(shí)現(xiàn)開合效果,還支持聲音效果。
下面是主要的代碼
//index.ui.js
var do_Animator1 = mm("do_Animator");
do_Animator1.append(500, {
y: -1334,
curve:"Linear"
});
var do_Animator2 = mm("do_Animator");
do_Animator2.append(500, {
y: 0,
curve:"Linear"
});
do_Page.on("NextPagemoveing", function(){
currentView=json_define[currentIndex].view;
currentIndex++;
if (currentIndex>=json_define.length) currentIndex=0;
nextView=json_define[currentIndex].view;
for(var i=0;i<json_define.length;++i){
if (json_define[i].view != currentView && json_define[i].view != nextView){
json_define[i].view.visible=false;
}
else{
json_define[i].view.visible=true;
}
}
currentView.fire("closingBottom", "NextPagemove");
});
do_Page.on("NextPagemove", function(){
nextView.fire("initMoving", "NextPagemoved");
});
do_Page.on("NextPagemoved", function(){
currentView.y= 0;
nextView.y= 1332;
do_ALayout_main.y=0;
do_ALayout_main.redraw();
do_ALayout_main.animate(do_Animator1, function(){
nextView.fire("opening");
});
});
do_Page.on("PrePagemoveing", function(){
currentView=json_define[currentIndex].view;
currentIndex--;
if (currentIndex<0) currentIndex=json_define.length -1;
nextView=json_define[currentIndex].view;
currentView.fire("closingHead", "PrePagemove");
});
do_Page.on("PrePagemove", function(){
nextView.fire("initMoving", "PrePagemoved");
});
do_Page.on("PrePagemoved", function(){
for(var i=0;i<json_define.length;++i){
if (json_define[i].view != currentView && json_define[i].view != nextView){
json_define[i].view.visible=false;
}
else{
json_define[i].view.visible=true;
}
}
currentView.y= 1332;
nextView.y= 0;
do_ALayout_main.y=-1334;
do_ALayout_main.redraw();
do_ALayout_main.animate(do_Animator2, function(){
nextView.fire("opening");
});
});
- IOS中各種手勢(shì)操作實(shí)例代碼
- iOS手勢(shì)的實(shí)現(xiàn)方法
- iOS 用Swipe手勢(shì)和動(dòng)畫實(shí)現(xiàn)循環(huán)播放圖片示例
- iOS手勢(shì)密碼的實(shí)現(xiàn)方法
- IOS 七種手勢(shì)操作(拖動(dòng)、捏合、旋轉(zhuǎn)、點(diǎn)按、長(zhǎng)按、輕掃、自定義)詳解及實(shí)例代碼
- IOS中的七種手勢(shì)小結(jié)
- iOS輕點(diǎn)、觸摸和手勢(shì)代碼開發(fā)
- 使用Swift代碼實(shí)現(xiàn)iOS手勢(shì)解鎖、指紋解鎖實(shí)例詳解
- IOS 單擊手勢(shì)的添加實(shí)現(xiàn)代碼
相關(guān)文章
javascript實(shí)現(xiàn)貪吃蛇小游戲思路
這篇文章主要為大家詳細(xì)介紹了javascript實(shí)現(xiàn)貪吃蛇思路小游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09
es6學(xué)習(xí)筆記之Async函數(shù)的使用示例
async 函數(shù),使得異步操作變得更加方便。它是 Generator 函數(shù)的語法糖。下面這篇文章主要給大家介紹了es6學(xué)習(xí)筆記之Async函數(shù)使用的相關(guān)資料,文中給出了詳細(xì)的示例代碼,需要的朋友們下面來一起看看吧。2017-05-05
JavaScript與DropDownList 區(qū)別分析
大家都知道,.NET中一些Web服務(wù)器控件解析并編譯,最終被渲染的時(shí)候,其實(shí)是轉(zhuǎn)化成了普通的html控件。2010-01-01
原生js實(shí)現(xiàn)移動(dòng)小球(碰撞檢測(cè))
這篇文章主要介紹了原生js實(shí)現(xiàn)會(huì)動(dòng)的小球,碰撞檢測(cè)功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-12-12

