-
-
Save gregorynicholas/8499870 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handlebars.registerHelper('renderTransitioningPage', function() { | |
console.log('----------------- here -------------------'); | |
var html = '', initial = true; | |
Deps.autorun(function() { | |
// this autorun with execute whenever currentPage or nextPage changes. | |
// we can inspect the two variables to determine exactly what's going on. | |
var current = Meteor.Transitioner.currentPage(), | |
next = Meteor.Transitioner.nextPage(); | |
console.log(current, next, initial); | |
if (initial) { | |
// render into html and return in this function. | |
// nextPage should always be false at this point | |
html = Template[current] ? Template[current]() : ''; | |
console.log(html); | |
initial = false; | |
return; | |
} | |
// if next is set, we are starting a transition. | |
// insert a #next-page element, and render in there | |
if (!! next) { | |
// next = 'loading'; | |
// var nextHtml = Template[next] ? Template[next]() : ''; | |
// console.log(nextHtml); | |
// console.log(Spark.isolate(function() { return nextHtml; })); | |
// | |
// nextHtml = '<div id="next-page">' + nextHtml + '</div>'; | |
var nextRange = LiveRange.findRange(Spark._TAG, | |
document.getElementById('next-page')); | |
console.log(nextRange); | |
Spark.renderToRange(nextRange, Template[next] || | |
function () { return ""; }); | |
// if next is unset, we have just finished a transition | |
// remove the old current page, and change next-page to current-page | |
} else { | |
// XXX: do we need to do something sparky to pull it out? | |
$('#current-page').detach(); | |
$('#next-page').attr('id', 'current-page'); | |
} | |
}); | |
// // first render currentPage into html, wrapped in #current-page | |
// var template = Template[Meteor.Router.page()] | |
// var html = template ? template() : ''; | |
console.log(html); | |
html = '<div id="current-page">' + html + '</div>'; | |
html = html + '<div id="next-page"/>'; | |
return new Handlebars.SafeString(html); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment