famo.us - how to implement mobile design hamburger side menu with famous? -
what's best way famous implement these known mobile app design patterns?
!) "hamburger" , side-menu like jasny example ?
2 )table-view, transitioning full-screen details page, little like: http://goratchet.com/examples/app-movies/
thanks!
you should aware famo.us university timbre menu lesson available. here version did long before came out. more of 1 file here critical issues implementations 27 class version. following did produce abstraction of menu generalized tool. there little difference between menu below , standard (one level deep) menu exception of transitions use. here drag-to-uncover menu. of course trigger open and/or close click well... can see code , play live @ codefamo.us.
/*globals define*/ define(function(require, exports, module) { 'use strict'; // import dependencies var engine = require('famous/core/engine'); var surface = require('famous/core/surface'); var transform = require('famous/core/transform'); var statemodifier = require('famous/modifiers/statemodifier'); var easing = require('famous/transitions/easing'); var containersurface = require('famous/surfaces/containersurface'); var eventhandler = require('famous/core/eventhandler'); var mousesync = require('famous/inputs/mousesync'); var touchsync = require('famous/inputs/touchsync'); var draggable = require('famous/modifiers/draggable'); var maincontext = engine.createcontext(); // content page... var coverstate = true; var coverpos = 0; //var covermod = new statemodifier(); var coverdrag = new draggable({ projection: 'x' }); var coversurface = new surface({ size:[undefined,undefined], content:'click open', properties:{ color:'white', backgroundcolor:'#44f', zindex:'3' } }); //maincontext.add(covermod).add(coverdrag).add(coversurface); maincontext.add(coverdrag).add(coversurface); coverdrag.activate(); function coverreset() { coverdrag.setposition([0,0], { duration : 100, curve: 'easeinout' }, function() { coversurface.setcontent('drag open'); coverpos = 0; } ); coverstate = true; } function coverdrawout() { coverdrag.setposition([200,0], { duration : 600, curve: 'easeinout' }, function() { coversurface.setcontent('drag close'); coverpos = 200; } ); coverstate=false; } coverdrag.on('update',function(data) { //console.log(data); if(data.position[0]>60) { menufadein(); } }); coverdrag.on('end',function(data) { if(data.position[0]<100) { coverreset(); menufadeout(); }else { coverdrawout(); menufadein(); } }); coversurface.pipe(coverdrag); // menu items... var todaysspecials = ['pizza','hamburger','french fries','ice cream']; var itemsurfs = []; var itemmod1 = []; var itemmod2 = []; // create menu item surfaces, modifiers, etc. (var i=0;i<todaysspecials.length;i++) { itemsurfs[i] = new surface({ size: [150, 30], content: '<span class="entypo">☰</span>'+todaysspecials[i], properties: { color: 'white', textalign: 'center', backgroundcolor: '#fa5c4f', zindex:'1' } }); itemsurfs[i].menudata = { id:i, text: todaysspecials[i] }; //console.log(itemsurfs[i]); itemmod1[i] = new statemodifier(); itemmod2[i] = new statemodifier(); maincontext.add(itemmod1[i]).add(itemmod2[i]).add(itemsurfs[i]); itemsurfs[i].on('click',function(mouseeventargs){ alert('buy '+mouseeventargs.origin.menudata.text); }); }; var menustate=true; // make menu go away function menufadeout() { if(menustate) { (var i=0;i<todaysspecials.length;i++) { itemmod1[i].settransform(transform.translate(-150, 200+i*40, 0)); itemmod2[i].settransform(transform.rotatez(-math.pi/5.5)); } menustate=false; } } // bring menu in function menufadein() { if(!menustate) { (var i=0;i<todaysspecials.length;i++) { itemmod1[i].settransform(transform.translate(0,100+i*40, -1),{ duration : 300+i*200, curve: 'easeinout' }); itemmod2[i].settransform(transform.rotatez(-math.pi/5.5)); } menustate=true; } } // app initial conditions... coverreset(); menufadeout(); });
Comments
Post a Comment