1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| export function autoSplitPages() { var blocks = $('.block') var group = [] var groupHeight = 0
blocks.map(function(index) { groupHeight += this.clientHeight console.log(this.clientHeight) var newPage = this.className.indexOf('newPage') > -1 var close = pageClose.bind(this)
if (groupHeight > 1000 || newPage) { close() } group.push(this)
if (index == blocks.length - 1) { close() } })
function pageClose() { console.log(groupHeight) console.log(group) groupHeight = this.clientHeight $(group).wrapAll(function() { return "<div class='phantomPaper'></div>" }) group = [] } }
|