Backbone.Marionette Fade Transition for only specific regions?

后端 未结 2 1125
暗喜
暗喜 2021-02-03 12:04

I know I can override all regions to add a fade transition by using the following.

Marionette.Region.prototype.open = function(view){
  this.$el.hide();
  this.$         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-03 13:09

    Another option that I just used was to override the open method for animations was to create a separate config file, override the open method in that config file, and conditional logic to test for className. So here's what I did with coffee script and using Marionette modules.

    Create my view:

    @Item.module "ItemApp.Add", (Add, App, Backbone, Marionette, $,_) ->
    
        class Add.Item extends Marionette.ItemView
    
            template: "#add-item"
            className: "add-modal"
    

    And in my config file I just test the className to perform the desired animation:

    do (Marionette) ->
        _.extend Marionette.Region::,
            open: (view) ->
                if view.el.className == "add-modal"
                    console.log "the add-modal has been called"
                    @$el.hide()
                    @$el.html(view.el)
                    @$el.show().animate "left": '0', queue: false
    

提交回复
热议问题