var app = (function() { var app = {} app.navigation_delay = 200 app.iscroll_options = { mouseWheel: true, scrollbars: true, click: is_android, } app.flickity_options = { cellAlign: 'left', contain: true, pageDots: false, wrapAround: true, } app.init = function() { app.bind() app.build() app.ready() } app.bind = function() { if (is_mobile) { document.addEventListener('touchmove', function(e) { e.preventDefault() }) FastClick.attach(document.body) } $(window).resize(app.resize) } app.build = function(data) { app.header = new HeaderView() app.nav = new NavView() var items = $(".item") app.lookup = {} app.projects = items.toArray().map(function(el, i){ var view = new ProjectView ({ el: el, page_number: i, }) app.lookup[ view.project_id ] = view return view }) } app.ready = function() { setTimeout(function(){ $("body").removeClass("loading") }, 20) app.router = new SiteRouter () 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(){ $(".item").each(function(i){ var height = window.innerHeight - $(this).find(".bottom").height() if (is_desktop) { height -= $("nav").height() // account for top bar } $(".previous, .next, .cell, .top, .flickity-viewport", this).css({ 'height': height }) $(".bottom", this).css({ 'top': height }) }) app.view.$el.removeClass("hidden") // $('.top').flickity('resize') $('body').removeClass('resizing') }, 400) }, 400) } return app })() $(".item").each(function(i){ var height = window.innerHeight - ($(this).find(".bottom").height() + 10) if (is_desktop) { height -= $("nav").height() // account for top bar } $(".cell, .top", this).css({ 'height': height }) $(".bottom", this).css({ 'top': height + 20 }) }) $('.top').each(function(){ if ($(this).find(".cell").length > 1) { $(this).flickity(app.flickity_options).on( 'cellSelect', function(e) { var gallery = $(e.target).data('flickity') app.header.updateSlideNumber( gallery.selectedIndex ) }) } }) $(".item").each(function(i){ var height = window.innerHeight - $(this).find(".bottom").height() if (is_desktop) { height -= $("nav").height() // account for top bar } $(".previous, .next, .flickity-viewport", this).css({ 'height': height }) }) $(".item").addClass("hidden") app.init()