Skip to content

Commit

Permalink
Make use of modulo for doSelectPreviousNextSource
Browse files Browse the repository at this point in the history
  • Loading branch information
ollimeier committed Oct 23, 2024
1 parent e2748b6 commit 2b3acdd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/fontra/views/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
isObjectEmpty,
loadURLFragment,
makeUPlusStringFromCodePoint,
modulo,
parseSelection,
range,
readFromClipboard,
Expand Down Expand Up @@ -2800,9 +2801,10 @@ export class EditorController {
...this.sceneSettings.glyphLocation,
});
} else {
const numSources = varGlyphController.sources.length;
newSourceIndex =
(selectPrevious ? sourceIndex + numSources - 1 : sourceIndex + 1) % numSources;
newSourceIndex = modulo(
sourceIndex + (selectPrevious ? -1 : 1),
varGlyphController.sources.length
);
}
this.sceneController.scrollAdjustBehavior = "pin-glyph-center";
this.sceneSettings.selectedSourceIndex = newSourceIndex;
Expand Down

0 comments on commit 2b3acdd

Please sign in to comment.