gadicc / meteor-famous-views

Famous, the Meteor Way (with Reactive Blaze Templates/Views)
http://famous-views.meteor.com/
GNU Lesser General Public License v3.0
332 stars 27 forks source link

RenderController: need a way to transition same template with new data #152

Open ghost opened 9 years ago

ghost commented 9 years ago

I have

main.hmtl

<template name="layout">
{{#famousContext id="mainCtx"}}
    {{#RenderController transition=getTransition overflow="hidden" id="layout"}}
        {{> yield}}
    {{/RenderController}}
{{/famousContext}}
</template>

and

router.js

this.route('single/started/:num', {
    name: 'started', 
    template: 'started',
    data: function () {
        return Tasks.findOne({ _id:  Session.get('taskId') });
    },
});

RenderController render pages normally with transitions when I go from different template names. Ex: from "About page" to "Home page" . But when I go from "started/1" to "started/2". No transitions.

Do I need something Router specific or destroy some famous stuff and recreate with something onBeforeAction?

gadicc commented 9 years ago

No, you don't need to do anything special. That behaviour is correct even if it's not what you're expecting. Because it's the same "route", and only the data is changing, Template.start is never removed and replaced with something else, which is what we use as the basis for transitions.

I think you could maybe do another RenderController inside of the start template, like:

{{#RenderController}}
  {{#with this}}
    {{>innerStartTemplate}}
  {{/with}}
{{/RenderController}}

that's just a guess but I think that should force the template to be removed and reinserted every time the data changes. If not, set up a repro on meteorpad and I'll play around a bit.

Note, to avoid unnecessary transitioning if the the document with that id changes, vs the document id changing, you'd have to do something about more finegrained.

ghost commented 9 years ago

I use meteorpad for the first time. Can u also edit it ?

http://meteorpad.com/pad/2awBes7CCnDpw7XXe/RenderContollr

gadicc commented 9 years ago

Omg, this is actually super hard... Meteor is too clever :> I got the transition working with a very hacky approach, but the problem is that you see the page update while it's transition out. We could turn off reactivity for that, but then you'll lose reactivity if the data updates on the same item. I guess I'm going to have to come up with something smart for cases like this, which disables reactivity when the transition starts. We'll have to leave this open for now.

Anyways, thanks for sending the code on meteorpad, makes things a lot easier. And yeah, I can fork, here's where I got to: http://meteorpad.com/pad/2KM6sistAyHwY6wab/Copy%20of%20RenderContollr

ghost commented 9 years ago

Thanks.. I think it is the easiest approach i tried and it is just ok for my use for now )))

I am going to look.. https://github.com/PEM--/MeetupFamousSlides/blob/master/lib/routing.coffee

gadicc commented 9 years ago

Yeah, that's much easier, because each slide is a different template.