Skip to content

Commit eca08df

Browse files
committed
Merge pull request #27 from XaserAcheron/feature-scroll
Made panel resizable
2 parents 407fda4 + 07cabac commit eca08df

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

lib/ember-cli-helper-view.coffee

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{Task, BufferedProcess} = require 'atom'
2-
{View} = require 'atom-space-pen-views'
2+
{$, View} = require 'atom-space-pen-views'
33
GeneratorListView = require './generator-list-view'
44
path = require 'path'
55
fs = require 'fs'
@@ -9,7 +9,8 @@ class EmberCliHelperView extends View
99

1010
@content: ->
1111
@div class: 'ember-cli-helper tool-panel panel-bottom native-key-bindings', =>
12-
@div class: 'ember-cli-btn-group', =>
12+
@div class: 'ember-cli-resize-handle', outlet: 'resizeHandle'
13+
@div class: 'ember-cli-btn-group', outlet: 'buttonGroup', =>
1314
@div class: 'block', =>
1415
@button outlet: 'switch', click: 'switchFile', class: 'btn btn-sm inline-block-tight', 'c/t'
1516
@button outlet: 'route', click: 'switchRoute', class: 'btn btn-sm inline-block-tight', 'r'
@@ -31,6 +32,9 @@ class EmberCliHelperView extends View
3132
"ember-cli-helper:open-component": => @openComponent()
3233
"ember-cli-helper:generate-file": => @showGeneratorList()
3334

35+
# Set up panel resizing
36+
@on 'mousedown', '.ember-cli-resize-handle', (e) => @resizeStarted(e)
37+
3438
# Add the path to the Node executable to the $PATH
3539
nodePath = atom.config.get('ember-cli-helper.pathToNodeExecutable')
3640
nodePath = nodePath.substring(0, nodePath.length - 4)
@@ -58,6 +62,7 @@ class EmberCliHelperView extends View
5862
destroy: ->
5963
@stopProcess()
6064
@clearPanel()
65+
@resizeStopped()
6166
@panel.removeClass 'hidden'
6267
@detach()
6368

@@ -73,6 +78,23 @@ class EmberCliHelperView extends View
7378
minimize: ->
7479
@panel.toggleClass 'hidden'
7580

81+
82+
# panel resizing code based on atom's tree-view package
83+
resizeStarted: =>
84+
$(document).on('mousemove', @resizePanel)
85+
$(document).on('mouseup', @resizeStopped)
86+
87+
resizeStopped: =>
88+
$(document).off('mousemove', @resizePanel)
89+
$(document).off('mouseup', @resizeStopped)
90+
91+
resizePanel: ({pageY, which}) =>
92+
return @resizeStopped() unless which is 1
93+
height = @outerHeight() + @offset().top - pageY
94+
barHeight = @buttonGroup.height();
95+
@panel.innerHeight(height - barHeight);
96+
97+
7698
getPathComponents: ->
7799
separator = path.sep
78100
editor = atom.workspace.getActivePaneItem()

styles/ember-cli-helper.less

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@
3434
}
3535
}
3636

37+
38+
// Panel resize handle
39+
.ember-cli-resize-handle {
40+
position: absolute;
41+
right: 0;
42+
left: 0;
43+
top: -5px;
44+
height: 10px;
45+
cursor: ns-resize;
46+
z-index: 3;
47+
}
48+
3749
}
3850

3951
.ember-cli-btn-group:extend(.btn-group) {

0 commit comments

Comments
 (0)