       h = toInt(style 'height') -
           toInt(style 'padding-top') -
           toInt(style 'padding-bottom')
+
       w = shift -
           toInt(style 'padding-left') -
           toInt(style 'padding-right')
 
       env.shift = shift * -1
-      env.s =
-        w: w
-        h: h
-
-    env
-
+      env.s = {w, h}
+
+    return env
+
+  setSize = (item) ->
+    return unless item.w > 0 and item.h > 0
+
+    getEnv()
+
+    s = scale item.w, item.h, env.s.w, env.s.h
+
+    item.img.width = s[0]
+    item.img.height = s[1]
+
+    setStyle item.slide, 'padding-top': "#{(env.s.h - s[1]) / 2}px"
+    return
 
   addEvent window, 'resize', ->
     needResize = true
+
     if isOpen
       opened.updateDimensions()
       opened.select opened.current
 
-  addEvent window, 'keyup', (event) =>
-    if isOpen && hasClass opened.overlay, choco_show
+    return
+
+  unless isTouch
+    addEvent window, 'keyup', (event) ->
+      if not isOpen or not hasClass opened.overlay, choco_show
+        return
+
       switch event.keyCode
         when 27 # ESC
           opened.close()


    if isOpen
      slide = getTarget opened.slider, ".#{choco}slide"
      return unless slide

      needResize = false


        when 39 # Right arrow
          opened.next()

window.chocolate = Chocolate
