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)
相关问题
- Backbone.js PushState routes .htaccess only workin
- Updating a LayoutView's Model
- Disable Backbone.js hashes entirely, but keep push
- Is there an easy way to distribute a Flask server
- React + Backbone, Target container is not a DOM el
相关文章
- Get all models in backbone collection where attrib
- How can I dynamically set a className for a Backbo
- Nesting Views within Views in backbone js
- Backbone-relational hasmany best practices
- JavaScript error: “is not a constructor”
- Marionette + i18n in templates
- Rendering reCAPTCHA v2.0 widget within Backbone vi
- Backbone.js PUT/DELETE problems with Codeigniter R
You could override the
close
function on the view, doing something like this:And do something similar with your
render
functions.I think this could be useful for you.
The following marionette plugin that adds 4 kind of transitions. There can be easily added more transition types.
Basically instead of using yourRegion.show(view)... you can use now yourRegion.showAnimated(view, {animationType: 'yourAnimation'});
it's very easy to use.
https://github.com/marcinkrysiak1979/marionette.showAnimated
see the documentation on github for more info
This seems to work for me:
For future users people could user my plugin for Transition Support in marionette.
https://github.com/saqibshakil/Marionette.TransitionRegion/
I used css3 transitions as those have more hardware support than jquery animations. on the downside using this makes the code async so be carefull of that.
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:Set How View's
el
Is AttachedIf 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.The default implementation of
open
is: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.This example will cause a view to slide down from the top of the region, instead of just appearing in place.