diff --git a/js/splitter.js b/js/splitter.js index fb9a577..903dd23 100644 --- a/js/splitter.js +++ b/js/splitter.js @@ -28,7 +28,29 @@ angular.module('bgDirectives', []) var drag = false; pane1.elem.after(handler); + + var initPane1 = (!isNaN(pane1.initSize)); + var initPane2 = (!isNaN(pane2.initSize)); + var initLOrT; + var initWOrH; + if (vertical) { + initLOrT = 'top'; + initWOrH = 'height'; + } else { + initLOrT = 'left'; + initWOrH = 'width'; + } + + if (initPane2) { + throw new Error("second pane cannot have init-size attribute"); + } + if (initPane1) { + handler.css( initLOrT, pane1.initSize + 'px'); + pane1.elem.css(initWOrH, pane1.initSize + 'px'); + pane2.elem.css(initLOrT, pane1.initSize + 'px'); + } + element.bind('mousemove', function (ev) { if (!drag) return; @@ -79,7 +101,8 @@ angular.module('bgDirectives', []) replace: true, transclude: true, scope: { - minSize: '=' + minSize: '=', + initSize: '=' }, template: '
', link: function(scope, element, attrs, bgSplitterCtrl) {