基於JS實現Android,iOS一個手勢動畫效果,androidios

來源:互聯網
上載者:User

基於JS實現Android,iOS一個手勢動畫效果,androidios

廢話不多說了,先給大家展示下:

這是iOS下的效果,android下完全一致。通過do_GestureView組件和do_Animation組件,deviceone能很容易實現複雜的跨平台純原生動畫效果,這個樣本就是通過手勢控製圖片上下動畫滑動實現開合效果,還支援聲音效果。

下面是主要的代碼

//index.ui.jsvar 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");});});

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.