Skip to content

Commit

Permalink
Make gpx.js a composable
Browse files Browse the repository at this point in the history
  • Loading branch information
steinbro committed Jul 13, 2024
1 parent ff1b42e commit 6da2153
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/ToolbarGPX.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import InputSpinner from './InputSpinner.vue';
import cache from '../state/cache.js';
import useAnnouncer from '../composables/announcer.js';
import { audioQueue, recentCallouts } from '../state/audio.js';
import replayGPX from '../utils/gpx.js';
import useGPX from '../composables/gpx.js';
import { myLocation } from '../state/location.js';
import { inject, ref } from 'vue';
Expand All @@ -75,7 +75,7 @@ const fileChanged = (event) => {
// Clear recent callout list
recentCallouts.value = [];
gpxPlayer = replayGPX(file, {
gpxPlayer = useGPX(file, {
// When GPX file has been loadedm trigger draw map at first point
loadedCallback: (firstPoint) => myLocation.setLocation(firstPoint.lat, firstPoint.lon),
// When GPX finishes playing, toggle to paused state and reset slider
Expand Down
6 changes: 3 additions & 3 deletions src/utils/gpx.js → src/composables/gpx.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Daniel W. Steinbrook.
// with many thanks to ChatGPT

import { HeadingCalculator } from './heading.js'
import { HeadingCalculator } from '../utils/heading.js'

const headingWindowSize = 5; // number of recent points to use for estimating heading

function replayGPX(file, callbacks) {
function useGPX(file, callbacks) {
const {
loadedCallback = () => {},
finishedCallback = () => {},
Expand Down Expand Up @@ -108,4 +108,4 @@ function replayGPX(file, callbacks) {
return gpxPlayer;
}

export default replayGPX;
export default useGPX;

0 comments on commit 6da2153

Please sign in to comment.