-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
altitude-slider: added altitude slider component
- Loading branch information
1 parent
3acf75b
commit b044fa3
Showing
5 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<template> | ||
<div v-if="showAltitudeSlider" class="slider-div"> | ||
<slider | ||
v-model="altitude_setpoint" | ||
orientation="vertical" | ||
width="100%" | ||
height="20" | ||
color="rgb(59 130 246)" | ||
track-color="rgb(59 130 246 / 0.5)" | ||
always-show-handle="true" | ||
step="0.1" | ||
/> | ||
<div class="slider-value"><span>Alt (Rel)</span></div> | ||
<div class="slider-value">{{ formattedValue }}</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed } from 'vue' | ||
import slider from 'vue3-slider' | ||
import { altitude_setpoint, showAltitudeSlider } from '@/libs/altitude-slider' | ||
const formattedValue = computed(() => altitude_setpoint.value.toFixed(1)) | ||
</script> | ||
<style scoped> | ||
.slider-value { | ||
white-space: nowrap; | ||
text-align: center; | ||
font-size: 0.8rem; | ||
} | ||
.slider-div { | ||
position: fixed; | ||
right: 2%; | ||
top: 25%; | ||
bottom: 0; | ||
width: 25px; | ||
height: 50%; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
z-index: 100; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ref, watch } from 'vue' | ||
|
||
export const showAltitudeSlider = ref(false) | ||
export const altitude_setpoint = ref(0) | ||
|
||
/** | ||
* Watches the altitude value for changes and updates the altitude accordingly. | ||
*/ | ||
watch(altitude_setpoint, (newValue, oldValue) => { | ||
console.log(`Altitude changed from ${oldValue} to ${newValue}`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters