               spliter.elem.remove()
             else
               if spliter.collapsable
-                spliter.preDivBoth = Math.max(preItem.size, 20) / (Math.max(nextItem.size, 20) + Math.max(nextItem.size, 20))
+                spliter.preDivBoth = Math.max(preItem.size, 20) / (Math.max(preItem.size, 20) + Math.max(nextItem.size, 20))
               splitersTmp.push spliter
               @spliterSizeTotal += spliter.size
           @spliters = splitersTmp

angular.module 'smart.layout', []
  .directive 'smartLayout', ['$parse', '$window', 'parseSize', ($parse, $window, parseSize) ->
    restrict: 'A'
    scope: true
    link: (scope, elem, attrs) ->

    toPixel: (size) ->
      size + 'px'
  ]
  .factory '_debounceResize', ['$timeout', '$window', ($timeout, $window) ->
    _debounce = (func, wait) ->
      timeout = null
      () ->
        context = this
        args = arguments
        later = () ->
          timeout = null
          func.apply(context, args)
        $timeout.cancel timeout if timeout
        timeout = $timeout later, wait
        return
    _debounce () ->
      angular.element($window).triggerHandler('resize')
      return
    , 300
  ]
