Created
May 3, 2016 18:25
-
-
Save simonmcmanus/ea5fa587ec04a29c868a3b788207e8a3 to your computer and use it in GitHub Desktop.
broken render with transitions for lnug
This file contains 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
'use strict' | |
var async = require('async') | |
var sizlate = require('sizlate') | |
var doSizlate = require('./do-sizlate') | |
var getFile = require('./read-file') | |
var loadComponents = require('./load-components') | |
/** | |
* used for client side render. | |
*/ | |
module.exports = function (page, callback) { | |
async.parallel({ | |
pageLayout: function (next) { | |
var pageLayoutPath = '/pages/' + page.page + '/' + page.page + '.html' | |
getFile(pageLayoutPath, next) | |
}, | |
components: function (next) { | |
if (page.spec) { | |
loadComponents(page.spec, next) | |
} else { | |
next() | |
} | |
} | |
}, function (err, data) { | |
if (err) { | |
return callback(err) | |
} | |
// this should not be hard coded. | |
$('nav a.active').removeClass('active'); | |
var outClass = 'pt-page-moveToBottomFade'; | |
var inClass = 'pt-page-moveFromTopFade'; | |
var $oldDiv = $('<div class="pt-page transition ' + outClass + '"></div>'); | |
$('#container').addClass('pt-main'); | |
var $oldWrap = $('#container').children().wrap($oldDiv) | |
//$('#container').addClass('pt-page-moveToLeft'); | |
var $newDiv = $('<div class="pt-page transition ' + inClass + '"></div>'); | |
$newDiv.html(data.pageLayout); | |
$('#container').append($newDiv); | |
var markup = doSizlate(page, $('html'), data.components); | |
setTimeout(function() { | |
var $children = $('.transition.' + inClass ).children(); | |
$('.transition.' + inClass).replaceWith($children); | |
$oldWrap.remove(); | |
}, 1000); | |
$('body').scrollTop($('#container')); | |
callback(null, markup) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment