Glide

A simple mobile framework

  • Transitions
  • Getting started
  • Created by
  • Contribute

Getting started

Using Glide

Glide is as a simple lightweight mobile framework. This guide will take you through some steps to get started. Further down we cover how to use Glide with backbone.js. Feedback welcome @hallodom

Features

  • glide.css gives scructure to your app making it easy to create fixed top or bottom positioned elements with native scrolling.
  • flight.js handles forwards and backwards page transitions.
  • We use fastclick.js to speed up clicks.
  • Extend Glide wih your own plugins.

Device Support

  • iPhone 3, 4 and 5
  • Android 4+
  • Android 2.3 (working solution)

Markup

Anatomy of a page

Include glide.js and css files. Make sure to include a theme.

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" href="css/glide.css">
    <link rel="stylesheet" href="css/glide.theme.css">
  </head>
  <body>

    <!-- pages here -->

    <script src="js/glide.js"></script>
    <script>
      window.glide = new Glide
    </script>
  </body>
</html>
              

Organise your app into pages. Make sure each page has the class .page and .hidden:

<div id="page-1" class="page hidden">
  <!-- page content -->
</div>

<div id="page-2" class="page hidden">
  <!-- page content -->
</div>
            

Glide will use the unique ID's to target the pages. Once you have some pages marked tell Glide to open the first page by passing the page id as a string to the to() function:

<script>
  window.glide = new Glide
  glide.to('#page-1')
</script>
            

That's all you need to get started.

Adding scrolling

Glide makes use of native scrolling [reference]. This solution does away with rubber banding on iOS without the need of a javscript solution. The solution requires three divs. Anything outside div.scrollview becomes a fixed positioned element:

<div id="page-1" class="page hidden">
  <!-- fixed header -->
  <div class="scrollview">
    <div class="scrollview-inner">
      <div class="scrollview-content">
        <!-- scrollable content here -->
      </div>
    </div>
  </div>
  <!-- fixed footer -->
</div>
            
  • Example fixed header/footer

Transitioning pages

Transitioning pages can be done in a router or using simple click events binding the glide.to() function. Glide does not watch for hash change events.

<a href="#page-2" id="#page-2-link" class="button">
  <button>Go to page 2</button>
</a>
            

In your javascript assign a click event to the anchor.

$('#page-2-link').on('click',function(){
  glide.to("#page-2");
});
            

Glide will perform the default slide transition to #page-2. You can make a back button with:

<div id="page-2">
  <a href="#page-1" class="back">
    <button>Back</button>
  </a>
</div>
            

We wrap a button within an anchor so we can pad the hit target to make it easier to tap. Then have some javascript to go back. When not using a router you must explicitly state back as true on Glide:

$('#page-2 a.back').on('click',function(){
  glide.back = true
  glide.to('#page-1')
});
            

Using the menu plugin

To use the menu plugin include the js and pass in a plugins has as options when instantiating Glide. We wrote the menu as a plugin so it's easier to build your own custom implmentations.

<script src="js/glide.menu.js"></script>
            
window.glide = new Glide({
  plugins: {
    menu: GlideMenu
  }
});
            

GlideMenu will look for the id #main-menu, make sure that is the ID for your menu markup. Now bind glide.plugins.menu.toggle() to your menu button:

$('#main-menu-button').on('click',function(e){
  e.preventDefault();
  glide.plugins.menu.toggle()
});
            
Hiding the menu can be calling toggle() again while the menu is open:
$('#close-menu-btn').on('click',function(e){
  e.preventDefault();
  glide.plugins.menu.toggle()
});
            

Using Glide with Backbone.js

We built Glide because we needed a flexible mobile framework that would work well with backbones router implementation. See the example below (written in coffeescript):

class AppRouter extends Backbone.Router

  routes:
    '': 'index'
    'getting-started': 'gettingStarted'
    'animations': 'animations'
    'slide': 'slide'
    'slideUp': 'slideUp'
    'contacts': 'contacts'
    'contacts/:id': 'showContact'

  index: ->
    glide.to '#index'

  gettingStarted: ->
    glide.to '#getting-started'

  animations: ->
    glide.to '#animations'

  slide: ->
    glide.to '#slide'

  slideUp: ->
    glide.to '#slideUp'

  contacts: ->
    view = new app.Views.Contacts collection: app.Collections.Contacts
    view.render()
    glide.to '#contacts'

  showContact: (id) ->
    model = app.Collections.Contacts?.get(id)
    view = new app.Views.ContactsShow model: model
    view.render()
    glide.to '#contact-page'

@app = window.app ? {}
@app.Routers.AppRouter = AppRouter
            

Above you can see how clean using Glide is when coupled with backbone routing. No need to worry about forward and back transitions, using glide.to() on each route has that all worked out for you.

View example app

To see Glide in full use view our example contacts app and take time to download and look through the source.

Transitions

  • Slide
  • Slide up

Slide

The slide transition

Slide is the default transition between pages. Glide will handle the forwards and back transitions for you.

Slide Up

The slide up transition

To apply slide up add data-transition="slideUp". Glide will figure out that this page has a slide up transition and will perform the reverse on the way back. Code example:

<div class="page hidden" data-transition="slideUp">
  <!-- content here -->
</div>

Contacts

Example

This is fixed

  • List item 1
  • List item 2
  • List item 3
  • List item 4
  • List item 5
  • List item 6
  • List item 7
  • List item 8
  • List item 9
  • List item 10
  • List item 11
  • List item 12
  • List item 13
  • List item 14
  • List item 15
  • List item 16
  • List item 17
  • List item 18
  • List item 19
  • List item 20
  • List item 21
  • List item 22
  • List item 23
  • List item 24
  • List item 25
  • List item 26
  • List item 27
  • List item 28
  • List item 29
  • List item 30

I could be a menu

Created by

Dom Briggs

UI Designer

www.hallodom.co.uk

dribbble.com/dominique.briggs

@hallodom


Made in Manchester at Capsule.

Contribute

Glide is under active development, follow the project on github.com/zestia/glide.

Here's the most direct way to get your work merged into the project:

  1. Fork the project
  2. Clone down your fork
  3. Create a feature branch
  4. Hack away
  5. If necessary, rebase your commits into logical chunks without errors
  6. Push the branch up to your fork
  7. Send a pull request for your branch

Add any issues in the Git issue tracker as quickly as possible.

  • Dominique Briggs
  • Menu item 1
  • Menu item 2
  • Menu item 3
  • Menu item 4
  • Menu item 5
  • Glide home page