Skip to content

Commit

Permalink
use switch
Browse files Browse the repository at this point in the history
  • Loading branch information
w-e-w committed Feb 8, 2023
1 parent 85dbe51 commit 31bbfa7
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions javascript/aspectRatioSliders.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,34 @@ class AspectRatioSliderController {
if (dimension == 'width') {
let newHeight = parseInt(this.widthSlider.getVal()) / ratio;
if (this.roundingSource.getVal()) {
if (this.roundingMethod.getVal() === "Ceiling"){
newHeight = Math.ceil(newHeight / 8) * 8;
}
else if (this.roundingMethod.getVal() === "Round"){
newHeight = Math.round(newHeight / 8) * 8;
}
else if (this.roundingMethod.getVal() === "Floor"){
newHeight = Math.floor(newHeight / 8) * 8;
switch (this.roundingMethod.getVal()){
case 'Round':
newHeight = Math.round(newHeight / 8) * 8;
break;
case 'Ceiling':
newHeight = Math.ceil(newHeight / 8) * 8;
break;
case 'Floor':
newHeight = Math.floor(newHeight / 8) * 8;
break;
}
}
this.heightSlider.setVal(newHeight.toString());
}
else if (dimension == "height") {
let newWidth = parseInt(this.heightSlider.getVal()) * ratio;
if (this.roundingSource.getVal()) {
newWidth = Math.ceil(newWidth / 8) * 8;
if (this.roundingMethod.getVal() === "Ceiling"){
}
else if (this.roundingMethod.getVal() === "Round"){
newWidth = Math.round(newWidth / 8) * 8;
}
else if (this.roundingMethod.getVal() === "Floor"){
newWidth = Math.floor(newWidth / 8) * 8;
switch (this.roundingMethod.getVal()){
case 'Round':
newWidth = Math.round(newWidth / 8) * 8;
break;
case 'Ceiling':
newWidth = Math.ceil(newWidth / 8) * 8;
break;
case 'Floor':
newWidth = Math.floor(newWidth / 8) * 8;
break;
}
newWidth = Math.ceil(newWidth / 8) * 8;
}
this.widthSlider.setVal(newWidth.toString());
}
Expand Down

0 comments on commit 31bbfa7

Please sign in to comment.