Skip to content

Commit

Permalink
Fix rotation functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Feb 15, 2024
1 parent 0e4bd95 commit daa6355
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 39 deletions.
20 changes: 16 additions & 4 deletions src/css/figure.css
Original file line number Diff line number Diff line change
Expand Up @@ -599,16 +599,28 @@
.image-display-options {
padding: 2px;
}
.rotation-slider {
display: none;
}
.rotation-controls-shown .rotation-slider {
height: 150px;
margin-left: 15px;
margin-top: 35px;
background: #666;
margin-left: 22px;
margin-top: 150px;
height: 2px;
background: #aaa;
transform: rotate(-90deg);
display: block;
width: 140px;
position: absolute;
transform-origin: left;
pointer-events: all;
}
.show-rotation {
padding: 2px;
min-width: 45px;
}
.rotation_value {
margin: -4px;
}
.z-projection {
padding: 1px 5px 5px;
}
Expand Down
52 changes: 18 additions & 34 deletions src/js/views/right_panel_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,22 @@
events: {
"click .show-rotation": "show_rotation",
"click .z-projection": "z_projection",
"input .rotation-slider": "rotation_input",
"change .rotation-slider": "rotation_change",
},

rotation_input: function(event) {
let val = parseInt(event.target.value);
$(".vp_img").css({'transform':'rotate(' + val + 'deg)'});
$(".rotation_value").text(val);
},

rotation_change: function(event) {
let val = parseInt(event.target.value);
this.rotation = val;
this.models.forEach(function(m){
m.save('rotation', val);
});
},

z_projection:function(e) {
Expand All @@ -1280,38 +1296,7 @@
},

show_rotation: function(e) {
var $rc = this.$el.find('.rotation-controls').toggleClass('rotation-controls-shown'),
self = this;

if ($rc.hasClass('rotation-controls-shown')) {
// $rc.find('.rotation-slider').slider({
// orientation: "vertical",
// max: 360,
// min: 0,
// step: 2,
// value: self.rotation,
// slide: function(event, ui) {
// $(".vp_img").css({'-webkit-transform':'rotate(' + ui.value + 'deg)',
// 'transform':'rotate(' + ui.value + 'deg)'});
// $(".rotation_value").text(ui.value);
// },
// stop: function( event, ui ) {
// self.rotation = ui.value;
// self.models.forEach(function(m){
// m.save('rotation', ui.value);
// });
// }
// });
} else {
// $rc.find('.rotation-slider').slider("destroy");
}
},

clear: function() {
try {
// this.$el.find('.rotation-slider').slider("destroy");
} catch (e) {}
return this;
this.$el.find('.rotation-controls').toggleClass('rotation-controls-shown');
},

render: function() {
Expand All @@ -1321,8 +1306,7 @@
sum_sizeZ = 0,
rotation,
z_projection,
zp,
self = this;
zp;
if (this.models) {
this.models.forEach(function(m, i){
rotation = m.get('rotation');
Expand Down
2 changes: 1 addition & 1 deletion src/templates/image_display_options.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<span class="rotation_value"><%= rotation %></span> &deg;
</button>

<div class="rotation-slider"></div>
<input type="range" class="rotation-slider" max="360" value="<%= rotation %>"></input>
</div>


Expand Down

0 comments on commit daa6355

Please sign in to comment.