         cube.yLast = cube.yDelta - (90 - mod)
 
     if cube.yLast % 90 isnt 0
-      console.log 'wtf'
       cube.yLast -= cube.yLast % 90
 
     cube.el.classList.remove 'no-tween'
     cube.el.style[transform] = @_getTransform cube.yLast
 
 
-  _onMouseOut: (e, cube) ->
+  _onTouchLeave: (e, cube) ->
     return unless @_touchStarted
-    @_onMouseUp e, cube if e.toElement and not cube.el.contains e.toElement
-
-
+    @_onTouchEnd e, cube if e.toElement and not cube.el.contains e.toElement
+
+
+

    "translate(0, 0) translateZ(-#{ @size }px) rotate3d(1, 0, 0, #{ deg }deg)"


  _onMouseDown: (e, cube) ->
    e.preventDefault()
    @_touchStarted = true
    e.currentTarget.classList.add 'no-tween'
    cube.y1 = e.pageY


  _onMouseMove: (e, cube) ->
    e.preventDefault()
    return unless @_touchStarted
    cube.diff = (e.pageY - cube.y1) * @_touchCoefficient
    cube.yDelta = cube.yLast - cube.diff
    @_setSides cube


  _onMouseUp: (e, cube) ->
    @_touchStarted = false
    mod = cube.yDelta % 90
    if mod < 45

      cube[side].style[css.transform] = "rotate3d(#{ rotate3d }) translate3d(0, 0, #{ @size / 2 }px)"
      cube.el.appendChild cube[side]

    eventPairs = [['TouchStart', 'MouseDown'], ['TouchMove', 'MouseMove'],
      ['TouchEnd', 'MouseUp'], ['TouchLeave', 'MouseOut']]

    for eventPair in eventPairs
      for eString in eventPair then do (fn = '_on' + eventPair[0], cube) =>
        cube.el.addEventListener eString.toLowerCase(), (e) =>
          @[fn] e, cube
        , true

    cube

