Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to manage route and data context? #3

Open
kk4sh opened this issue Jan 29, 2015 · 11 comments
Open

How to manage route and data context? #3

kk4sh opened this issue Jan 29, 2015 · 11 comments

Comments

@kk4sh
Copy link

kk4sh commented Jan 29, 2015

Few questions...

Is there a way to use transition for the same route with a different datacontext ?

In this case, how to manage the helper params

fromRoute: 'page/:id',
toRoute: 'page/:id'

Can you provide a sample demo for this case?

To manage the waitOn perhaps use the subscriptions instead which doesnt force the loading template to be rendered?

Thank you

@ccorcos
Copy link
Owner

ccorcos commented Jan 29, 2015

This package works by route name. So try from "post" and to "post". Does that work?

@kk4sh
Copy link
Author

kk4sh commented Jan 29, 2015

seems to work but not really in my use case ( the yield data just vanish) pad
if you have any idea..

@ccorcos
Copy link
Owner

ccorcos commented Jan 29, 2015

Ah. The problem is that the template doesnt change so it doesnt know what to animation. _uihooks never gets called... You will need to trigger these animations manually...

@etmarch
Copy link

etmarch commented Jan 29, 2015

My data was 'vanishing' on every route too, I found that simply removing the css class "overflow: hidden' solved it for me.

@ccorcos
Copy link
Owner

ccorcos commented Jan 30, 2015

There may be issues with data context until the next meteor version. Theres a PR about Template.instance() and template data context getting messed up with Template block helpers.

@funwithtriangles
Copy link

@ccorcos could you point me in the right direction on how to manually trigger the animations? I'm currently dealing with a setup where I'm trying to transition between two routes using the same template but to no effect...

@ccorcos
Copy link
Owner

ccorcos commented Feb 9, 2015

So trick here is that I'm using _uihooks to trigger animations when blaze inserts or removes templates. However, if you route between the same template, then there is no insert or remove happening at the {{>yield}} level, thus the transitioner cannot animate it.

If you want to animate manually, then just use VelocityJS. But you will have a problem that Blaze is using the exact same DOM elements for both templates.

@ccorcos
Copy link
Owner

ccorcos commented Feb 9, 2015

@iamalexkempton check out my animation package for simple animations. It won't allow you to animate between those routes, because of the previously stated issue, but you could animate how the individual elements change.

@funwithtriangles
Copy link

@ccorcos Thanks for the explanation Chet! This put me in a bit of a pickle. Funnily enough, I'm actually trying to do a "swipe between pages" sort of thing, but your other library only seems to work for non-dynamic routes. I've got a big app with lots of pages that I'd like to swipe between but the routes are of the /page/gvR2yrYgooEwzQbLR sort. Seems like I'm stuck either way. Any ideas?

@ccorcos
Copy link
Owner

ccorcos commented Feb 9, 2015

Oy. Thats rough! Here's an idea for you, but its a little involved. You won't be able to swipe necessarily but you can use transitioner.

You can try something like this

<template name="postwrapper">
{{#transitioner}}
    {{>Template.dynamic template=first}}
    {{>Template.dynamic template=second}}
{{/transitioner}}
</template>

Then create a variable to keep track of which one you're looking at. Session.set('current' ,true)

Then do something like this:

Template.postwrapper.helpers
  first: -> if Session.get('current') is true then 'post' else ''
  second: -> if Session.get('current') is false then 'post' else ''

Route 'postwrapper', 
    path: 'post/:_id`
    action: ->
      Session.set('current', not Session.get('current'))

So what you're doing is forcing Blaze to render a new post template in the 'second' Template.dynamic and removing the post template from the 'first'.

I hope it works for you! This should allow you to use the transitioner. :)

@funwithtriangles
Copy link

@ccorcos Thanks for your input Chet! Hopefully I'll be able to work something out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants