Listening to Transition Events

Listening to Transition Events Authors: Yoshiroh KamiyamaThere are two ways to listen to varIoUs transition events,connect and pub/sub.Connect to Transition EventsThe View widget has five stub methods,onStartView,onBeforeTransitionIn,onAfterTransitionIn,onBeforeTransitionOut,and onAfterTransitionOut,to which you can connect.onStartViewSummaryA method that is called only when this view is shown at startup time. That is,if the view is invisible at startup time and then becomes visible as a result of a view transition,onStartView does NOT fire.SyntaxonStartView()Example// 'connect' is the return value of the module dojo/_base/connectconnect.connect(view1,"onStartView",null,function(){ console.log("startView: view="+this);});onBeforeTransitionInSummaryA method that is called immediately before a view transition that makes this view visible.SyntaxonBeforeTransitionIn(moveto,dir,transition,context,method)moveto - The destination view id to transition the current view to.dir - The transition direction. If 1,transition forward. If -1,transition backward.transition - The name of transition to perform. Ex. “slide”context - The object that the callback function will receive as “this”.method - A callback function that is called when the transition has finished.Example// 'connect' is the return value of the module dojo/_base/connectconnect.connect(view1,"onBeforeTransitionIn",function(moveto,method){ print("onBeforeTransitionIn");});onAfterTransitionInSummaryA method that is called immediately after a view transition that makes this view visible.SyntaxonAfterTransitionIn(moveto,"onAfterTransitionIn",method){ print("afterTransitionIn");});onBeforeTransitionOutSummaryA method that is called immediately before a view transition that makes this view hidden.SyntaxonBeforeTransitionOut(moveto,"onBeforeTransitionOut",method){ print("onBeforeTransitionOut");});onAfterTransitionOutSummaryA method that is called immediately after a view transition that makes this view hidden.SyntaxonAfterTransitionOut(moveto,"onAfterTransitionOut",method){ print("afterTransitionOut");});Subscribe Transition EventsThe View widget publishes five topics that are related to view transition./dojox/mobile/startViewSummaryA topic that is published only when this view is shown at startup time. That is,the view does NOT publish this topic.Topic Subscriberfunction(view)view - A view that initiated the view transition.Example// 'connect' is the return value of the module dojo/_base/connectconnect.subscribe("/dojox/mobile/startView",function(view){ console.log("startView: view="+view);});/dojox/mobile/beforeTransitionInSummaryA topic that is published immediately before a view transition that makes this view visible.Topic Subscriberfunction(view,moveto,method)view - The destination viewmoveto - The destination view id to transition the current view to.dir - The transition direction. If 1,transition backward.transition - The name of transition to perform. Ex. “slide”context - The object that the callback function will receive as “this”.method - A callback function that is called when the transition has finished.Example// 'connect' is the return value of the module dojo/_base/connectconnect.subscribe("/dojox/mobile/beforeTransitionIn",function(view,method){ print("onBeforeTransitionIn");});/dojox/mobile/afterTransitionInSummaryA topic that is published immediately after a view transition that makes this view visible.Topic Subscriberfunction(view,transition backward.transition - The name of transition to perform. Ex. “slide”context - The object that the callback function will receive as “this”.method - A callback function that is called when the transition has finished.Example// 'connect' is the return value of the module dojo/_base/connectconnect.subscribe("/dojox/mobile/afterTransitionIn",method){ print("afterTransitionIn");});/dojox/mobile/beforeTransitionOutSummaryA topic that is published immediately before a view transition that makes this view hidden.Topic Subscriberfunction(view,method)view - The start view. (A view that initiated the transition)moveto - The destination view id to transition the current view to.dir - The transition direction. If 1,transition backward.transition - The name of transition to perform. Ex. “slide”context - The object that the callback function will receive as “this”.method - A callback function that is called when the transition has finished.Example// 'connect' is the return value of the module dojo/_base/connectconnect.subscribe("/dojox/mobile/beforeTransitionOut",method){ print("onBeforeTransitionOut");});/dojox/mobile/afterTransitionOutSummaryA topic that is published immediately after a view transition that makes this view hidden.Topic Subscriberfunction(view,transition backward.transition - The name of transition to perform. Ex. “slide”context - The object that the callback function will receive as “this”.method - A callback function that is called when the transition has finished.Exampledojo.subscribe("/dojox/mobile/afterTransitionOut",method){ print("afterTransitionOut");});Reference GuideDojo Version StartpageDojoDijitDojoXTable Of ContentsListening to Transition EventsConnect to Transition EventsonStartViewonBeforeTransitionInonAfterTransitionInonBeforeTransitionOutonAfterTransitionOutSubscribe Transition Events/dojox/mobile/startView/dojox/mobile/beforeTransitionIn/dojox/mobile/afterTransitionIn/dojox/mobile/beforeTransitionOut/dojox/mobile/afterTransitionOutPrevIoUs topicTemplating dojox/mobile widgetsNext topicdojox/mvcQuick search转自:http://dojotoolkit.org/reference-guide/1.9/dojox/mobile/transition-events.html#dojox-mobile-transition-events

相关文章

我有一个网格,可以根据更大的树结构编辑小块数据.为了更容易...
我即将开始开发一款教育性的视频游戏.我已经决定以一种我可以...
我正在使用带有Grails2.3.9的Dojo1.9.DojoNumberTextBox小部...
1.引言鉴于个人需求的转变,本系列将记录自学arcgisapiforja...
我正在阅读使用dojo’sdeclare进行类创建的语法.描述令人困惑...
我的团队由更多的java人员和JavaScript经验丰富组成.我知道这...