code: function(state1, state2) {
  
  		// if state1 is undefined, return state2 + isEqual=false and velocity=0 as delta
  		if(!state1 || !state2)
  			return angular.extend(
  				{isEqual: false, velocityX: 0, velocityY: 0},
  				state2
  			);
  
  		// calculate delta of state1 and state2
  		var delta= {
  			posX: state2.posX - state1.posX,
  			posY: state2.posY - state1.posY,
  			width: state2.width - state1.width,
  			height: state2.height - state1.height,
  			maxWidth: state2.maxWidth - state1.maxWidth,
  			maxHeight: state2.maxHeight - state1.maxHeight,
  		};
  
  		// add velocity information
  		if(state2.width > 0)
  			delta.velocityX= delta.posX / state2.width;
  		if(state2.height > 0)
  			delta.velocityY= delta.posY / state2.height;
  
  		// if any property is not 0, the delta is not zero
  		delta.isEqual= !(
  			delta.posX !== 0 ||
  			delta.posY !== 0 ||
  			delta.width !== 0 ||
  			delta.height !== 0 ||
  			delta.maxWidth !== 0 ||
  			delta.maxHeight !== 0
  		);
  
  		return delta;
  	}
docs: calculate difference between last state and current state