Skip to content

Commit

Permalink
Merge remote-tracking branch 'Rdornier/align-right-bottom' into vite
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Feb 15, 2024
2 parents 12bce37 + 88c9e38 commit 8276fb0
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/css/figure.css
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
line-height: 20px;
padding: 12px 5px;
position: absolute;
right: 485px;
right: 520px;
text-align: center;
height: 100%;
}
Expand Down Expand Up @@ -923,6 +923,10 @@
transform: rotate(90deg);
display: inline-block;
}
.abottom i {
transform: rotate(270deg);
display: inline-block;
}

.navbar-left .btn-sm {
font-size: 14px;
Expand Down
15 changes: 15 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,13 @@ <h5>Example Label</h5>
>
<i class="bi-text-left"></i>
</button>
<button
type="button"
class="aright btn btn-sm btn-light"
title="Align Right"
>
<i class="bi-text-right"></i>
</button>
<button
type="button"
class="agrid btn btn-sm btn-light"
Expand Down Expand Up @@ -1444,6 +1451,14 @@ <h5>Example Label</h5>
>
<i class="bi-text-left"></i>
</button>
<button
type="button"
disabled
class="abottom btn btn-sm btn-light"
title="Align Bottom"
>
<i class="bi-text-left"></i>
</button>
<button
type="button"
class="btn btn-sm btn-light dropdown-toggle"
Expand Down
27 changes: 27 additions & 0 deletions src/js/models/figure_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,20 @@
});
},


align_right: function() {
var selected = this.getSelected(),
x_vals = [];
selected.forEach(function(p){
x_vals.push(p.get('x') + p.get('width'));
});
var max_x = Math.max.apply(window, x_vals);

selected.forEach(function(p){
p.save('x', max_x - p.get('width'));
});
},

align_top: function() {
var selected = this.getSelected(),
y_vals = [];
Expand All @@ -626,6 +640,19 @@
});
},

align_bottom: function() {
var selected = this.getSelected(),
y_vals = [];
selected.forEach(function(p){
y_vals.push(p.get('y') + p.get('height'));
});
var max_y = Math.max.apply(window, y_vals);

selected.forEach(function(p){
p.save('y', max_y - p.get('height'));
});
},

align_grid: function(gridGap) {
var sel = this.getSelected(),
top_left = this.get_top_left_panel(sel),
Expand Down
12 changes: 12 additions & 0 deletions src/js/views/figure_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,8 @@
"click .aleft": "align_left",
"click .agrid": "align_grid",
"click .atop": "align_top",
"click .aright": "align_right",
"click .abottom": "align_bottom",

"click .awidth": "align_width",
"click .aheight": "align_height",
Expand Down Expand Up @@ -945,6 +947,16 @@
this.model.align_top();
},

align_right: function(event) {
event.preventDefault();
this.model.align_right();
},

align_bottom: function(event) {
event.preventDefault();
this.model.align_bottom();
},

custom_grid_gap: function() {
let current = $("#custom_grid_gap").attr("value");
// simple propmt to ask user for custom grid gap
Expand Down

0 comments on commit 8276fb0

Please sign in to comment.