Skip to content

Commit

Permalink
Handle even no. of z-levels correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Joakim Lindblad authored and joakimlindblad committed Sep 13, 2021
1 parent 0454caa commit 75c459c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions public/js/tmapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@ const tmapp = (function() {

function _setFocusLevel(z) {
const count = _viewer.world.getItemCount();
const max = Math.floor(count / 2);
const min = -max;
z = Math.min(Math.max(z,min),max);
for (let i = min; i <= max; i++) {
let idx = i + Math.floor(_currentImage.zLevels.length / 2);
_viewer.world.getItemAt(idx).setOpacity(z == i);
const ofs = Math.floor(_currentImage.zLevels.length / 2);
z = Math.min(Math.max(z,-ofs),count-1-ofs);
for (let i = 0; i < count; ++i) {
_viewer.world.getItemAt(i).setOpacity(z+ofs == i);
}
_currState.z = z;
_updateFocus();
Expand Down

0 comments on commit 75c459c

Please sign in to comment.