Skip to content

Commit

Permalink
Merge pull request #1745 from googlefonts/issue-1743-use-modulo-for-d…
Browse files Browse the repository at this point in the history
…oSelectPreviousNextSource

Make use of modulo for doSelectPreviousNextSource
  • Loading branch information
ollimeier authored Oct 23, 2024
2 parents 058ec9b + 2b3acdd commit c78e675
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 @@ -2801,9 +2802,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 c78e675

Please sign in to comment.