var app = (function() { var app = {} app.iscroll_options = { mouseWheel: true, scrollbars: true, click: is_android, } app.flickity_options = { cellAlign: 'left', contain: true, pageDots: false, wrapAround: true, arrowShape: { x0: 10, x1: 35, y1: 25, x2: 40, y2: 25, x3: 15 } } 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(){ $(".cell, .next, .previous").css({ 'display': 'none' }) $('body').addClass('resizing') debounce(function() { $(".cell, .next, .previous").css({ 'height': ($(".top").height() + 'px'), 'display': 'inline-block' }) $('.top').flickity('resize') $('body').removeClass('resizing') }, 400) } return app })() $(".cell, .next").css({ 'height': ($(".top").height() + 'px') }) $('.top').flickity(app.flickity_options).on( 'cellSelect', function(e) { var gallery = $(e.target).data('flickity') app.header.updateSlideNumber( gallery.selectedIndex ) }) $(".previous, .next").css({ 'height': ($(".top").height() + 'px') }) app.init()