骨干木偶 - 切换视图时添加的视觉效果 [英] Backbone Marionette - Add a visual effect when switching view
问题描述
有没有当我离开一个页面(关闭视图/布局)添加效果,打开在同一地区一个新的便捷方式? (有点像淡入淡出效果)
Is there a convenient way to add an effect when I leave a page (close a view/layout) and open a new one in the same region ? (something like a fade effect)
推荐答案
木偶地区有一个名为方法打开
,默认情况下只需更换旧观点与的HTML新的看法。您可以覆盖这个方法做任何你喜欢的动画。从<一个href=\"https://github.com/derickbailey/backbone.marionette/blob/master/docs/marionette.region.md\">region文档:
Marionette regions have a method called open
that by default just replace the HTML of the old view with the new view. You can override this method to do any animation you like. From the region documentation:
如果您需要更改视图如何连接到DOM时
通过展示区域的观点,覆盖的的打开
方法
地区。这个方法接收一个参数 - 视图以显示
If you need to change how the view is attached to the DOM when
showing a view via a region, override the open
method of the
region. This method receives one parameter - the view to show.
的默认实现打开
是:
Marionette.Region.prototype.open = function(view){
this.$el.html(view.el);
}
这将与视图的替换区域的内容报
/内容。您可以更改您希望这是任何东西,
虽然,有利于过渡效果和更多的。
This will replace the contents of the region with the view's
el
/ content. You can change to this be anything you wish,
though, facilitating transition effects and more.
Marionette.Region.prototype.open = function(view){
this.$el.hide();
this.$el.html(view.el);
this.$el.slideDown("fast");
}
此示例将导致以从顶部向下滑动
该区域的,而不是仅仅出现在的地方。
This example will cause a view to slide down from the top of the region, instead of just appearing in place.
这篇关于骨干木偶 - 切换视图时添加的视觉效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!