Committed by
Gerrit Code Review
GUI -- ToolbarService and PanelService show and hide panels based on margin and …
…hideMargin, and fade is a setting. Change-Id: I85b5dd447df09e13e9308473c548621d4b76fa15
Showing
3 changed files
with
17 additions
and
11 deletions
... | @@ -26,7 +26,9 @@ | ... | @@ -26,7 +26,9 @@ |
26 | edge: 'right', | 26 | edge: 'right', |
27 | width: 200, | 27 | width: 200, |
28 | margin: 20, | 28 | margin: 20, |
29 | - xtnTime: 750 | 29 | + hideMargin: 20, |
30 | + xtnTime: 750, | ||
31 | + fade: true | ||
30 | }; | 32 | }; |
31 | 33 | ||
32 | var panels, | 34 | var panels, |
... | @@ -45,6 +47,9 @@ | ... | @@ -45,6 +47,9 @@ |
45 | function margin(p) { | 47 | function margin(p) { |
46 | return p.settings.margin; | 48 | return p.settings.margin; |
47 | } | 49 | } |
50 | + function hideMargin(p) { | ||
51 | + return p.settings.hideMargin; | ||
52 | + } | ||
48 | function noPx(p, what) { | 53 | function noPx(p, what) { |
49 | return Number(p.el.style(what).replace(/px$/, '')); | 54 | return Number(p.el.style(what).replace(/px$/, '')); |
50 | } | 55 | } |
... | @@ -58,7 +63,7 @@ | ... | @@ -58,7 +63,7 @@ |
58 | return margin(p) + 'px'; | 63 | return margin(p) + 'px'; |
59 | } | 64 | } |
60 | function pxHide(p) { | 65 | function pxHide(p) { |
61 | - return (-margin(p) - widthVal(p)) + 'px'; | 66 | + return (-hideMargin(p) - widthVal(p) - (noPx(p, 'padding') * 2)) + 'px'; |
62 | } | 67 | } |
63 | 68 | ||
64 | function makePanel(id, settings) { | 69 | function makePanel(id, settings) { |
... | @@ -105,12 +110,13 @@ | ... | @@ -105,12 +110,13 @@ |
105 | } | 110 | } |
106 | 111 | ||
107 | function hidePanel(cb) { | 112 | function hidePanel(cb) { |
108 | - var endCb = fs.isF(cb) || noop; | 113 | + var endCb = fs.isF(cb) || noop, |
114 | + endOpacity = p.settings.fade ? 0 : 1; | ||
109 | p.on = false; | 115 | p.on = false; |
110 | p.el.transition().duration(p.settings.xtnTime) | 116 | p.el.transition().duration(p.settings.xtnTime) |
111 | .each('end', endCb) | 117 | .each('end', endCb) |
112 | .style(p.settings.edge, pxHide(p)) | 118 | .style(p.settings.edge, pxHide(p)) |
113 | - .style('opacity', 0); | 119 | + .style('opacity', endOpacity); |
114 | } | 120 | } |
115 | 121 | ||
116 | function togglePanel(cb) { | 122 | function togglePanel(cb) { | ... | ... |
... | @@ -22,9 +22,7 @@ | ... | @@ -22,9 +22,7 @@ |
22 | position: absolute; | 22 | position: absolute; |
23 | z-index: 100; | 23 | z-index: 100; |
24 | display: block; | 24 | display: block; |
25 | - top: 75px; /* TODO: change this to proper height*/ | ||
26 | width: 200px; | 25 | width: 200px; |
27 | - right: -220px; | ||
28 | opacity: 0; | 26 | opacity: 0; |
29 | 27 | ||
30 | padding: 10px; | 28 | padding: 10px; | ... | ... |
... | @@ -25,7 +25,10 @@ | ... | @@ -25,7 +25,10 @@ |
25 | var ids = [], | 25 | var ids = [], |
26 | defaultSettings = { | 26 | defaultSettings = { |
27 | edge: 'left', | 27 | edge: 'left', |
28 | - width: 400 | 28 | + width: 400, |
29 | + margin: 0, | ||
30 | + hideMargin: -20, | ||
31 | + fade: false | ||
29 | }, | 32 | }, |
30 | settings, | 33 | settings, |
31 | arrowSize = 10, | 34 | arrowSize = 10, |
... | @@ -49,7 +52,7 @@ | ... | @@ -49,7 +52,7 @@ |
49 | return true; | 52 | return true; |
50 | } | 53 | } |
51 | 54 | ||
52 | - // translate(0 50) looks good with arrowSize of 10 | 55 | + // translate uses 50 because the svg viewbox is 50 |
53 | function rotateArrowLeft() { | 56 | function rotateArrowLeft() { |
54 | tbarArrowDiv.select('g') | 57 | tbarArrowDiv.select('g') |
55 | .attr('transform', 'translate(0 50) rotate(-90)'); | 58 | .attr('transform', 'translate(0 50) rotate(-90)'); |
... | @@ -57,14 +60,14 @@ | ... | @@ -57,14 +60,14 @@ |
57 | 60 | ||
58 | function rotateArrowRight() { | 61 | function rotateArrowRight() { |
59 | tbarArrowDiv.select('g') | 62 | tbarArrowDiv.select('g') |
60 | - .attr('transform', 'translate(0 50) rotate(90)'); | 63 | + .attr('transform', 'translate(50 0) rotate(90)'); |
61 | } | 64 | } |
62 | 65 | ||
63 | function createArrow() { | 66 | function createArrow() { |
64 | tbarArrowDiv = tbarDiv.append('div') | 67 | tbarArrowDiv = tbarDiv.append('div') |
65 | .classed('tbarArrow', true) | 68 | .classed('tbarArrow', true) |
66 | .style({'position': 'absolute', | 69 | .style({'position': 'absolute', |
67 | - 'top': '50%', | 70 | + 'top': '53%', |
68 | 'left': '98%', | 71 | 'left': '98%', |
69 | 'margin-right': '-2%', | 72 | 'margin-right': '-2%', |
70 | 'transform': 'translate(-50%, -50%)', | 73 | 'transform': 'translate(-50%, -50%)', |
... | @@ -151,7 +154,6 @@ | ... | @@ -151,7 +154,6 @@ |
151 | 154 | ||
152 | function hide(cb) { | 155 | function hide(cb) { |
153 | tbarPanel.hide(cb); | 156 | tbarPanel.hide(cb); |
154 | - //tbarPanel.style(opts.edge, (arrowSize + 4 + 'px')); | ||
155 | rotateArrowRight(); | 157 | rotateArrowRight(); |
156 | } | 158 | } |
157 | 159 | ... | ... |
-
Please register or login to post a comment