var app = (function() { var app = {} app.navigation_delay = 150 app.iscroll_options = { mouseWheel: true, scrollbars: true, click: is_android, } app.flickity_options = { cellAlign: 'left', contain: true, pageDots: false, wrapAround: true, accessibility: false, } app.init = function() { app.build() app.bind() app.ready() } app.bind = function() { if (is_mobile) { document.addEventListener('touchmove', function(e) { e.preventDefault() }) window.FastClick && FastClick.attach(document.body) } $(window).resize(app.resize) } app.build = function(data) { app.loader = new Loader () app.header = new HeaderView() app.nav = new NavView() app.$items = $(".item") app.resizeItems() app.lookup = {} app.projects = app.$items.toArray().map(function(el, i){ var view = new ProjectView ({ el: el, page_number: i, }) app.lookup[ view.project_id ] = view return view }) Scroller.init({ previous: app.nav.previous.bind(app.nav), next: app.nav.next.bind(app.nav), burger: app.header.toggleNav.bind(app.nav), left: function(){ var gallery = $('.item.active .top').data('flickity') gallery && gallery.previous() }, right: function(){ var gallery = $('.item.active .top').data('flickity') gallery && gallery.next() }, }) } app.ready = function() { setTimeout(function(){ $("body").removeClass("loading") }, 20) // app.header.startTime() app.router = new SiteRouter () app.resizeItems() app.router.launch() console.log("launched") } app.resize = function(){ // $(".active .cell,.active .next,.active .previous").css({ 'display': 'none' }) $('body').addClass('resizing') debounce(function() { $(".active.item").addClass("hidden") setTimeout(function(){ app.resizeItems() app.view.$el.removeClass("hidden") // $('.top').flickity('resize') $('body').removeClass('resizing') }, 400) }, 400) } app.resizeItems = function(){ var windowHeight = window.innerHeight var navHeight = $("nav").height() if (is_iphone) { windowHeight -= 22 // account for lower bar window.scrollTo(0,0) $(".menu").height( windowHeight + 16 - navHeight ) if (app.menu && app.menu.scroller) { app.menu.scroller.refresh() app.menu.scroller.scrollTo(0, 0) } } $(".item").each(function(i){ var height = windowHeight - ($(this).find(".bottom").height() + 10) if (is_desktop) { height -= navHeight // account for top bar } $(".cell, .top, .previous, .next, .flickity-viewport", this).css({ 'height': height }) var cellCount = $(this).find(".cell").length if ($.browser.mozilla) { $(".bottom", this).css({ 'top': height + 20 }) } else { if (cellCount == 0) { $(".bottom", this).css({ 'top': height + 17 }) } else if (cellCount == 1) { $(".bottom", this).css({ 'top': height + 20 }) } else { $(".bottom", this).css({ 'top': height + 19 }) } } }) } return app })() app.init()