To build on yesterday’s tip let’s look at a simple example indicating the direction of our users touch. # app/assets/javascripts/touch_handler.js.coffee   movement = element: $(’body’) startingPointX: 0 startingPointY: 0   movement.touching = (e) -> e = e.originalEvent   touchObject = e.changedTouches[0]   point = if e.touches then e.touches[0] else e movement.startingPointX = point.pageX movement.startingPointY = point.pageY   movement.deltaX = touchObject.pageX – movement.startingPointX movement.deltaY = touchObject.pageY – movement.startingPointY   if Math.abs(movement.deltaY) < Math.abs(movement.deltaX) console.log "Moving horizontal" else console.log "Moving vertical"   movement.element.bind ‘touchmove’, movement.touching

Although not Ruby, Coffeescript is part of every Rails developer’s toolkit now, and with front-end development comes the responsibility of responsive design. Today we look at how to grab a moving finger on a mobile device. In part two we will look at how to test the direction of a moving finger. # app/assets/javascripts/touch_handler.js.coffee   movement = element: $(’body’) startingPointX: 0 startingPointY: 0   movement.touching = (e) -> e = e.originalEvent point = if e.touches then e.touches[0] else e movement.startingPointX = point.pageX movement.startingPointY = point.pageY console.log movement.startingPointX console.log movement.startingPointy   movement.element.bind ‘touchmove’, movement.touching

Building beta sites can become cluttered with statements, but Rails before_actions make it easy to lock down sections of web applications without flow control in views. class PagesController < ApplicationController   before_action :redirect_unless_live, only: [:tickets, :shows, :press]   def press; end def shows; end def tickets; end   home # ready for production end   private   def redirect_unless_live return unless current_user.beta_access? redirect_to root_path end   end