Skip to content

Commit

Permalink
fix animations: remove some vue-slider-components
Browse files Browse the repository at this point in the history
  • Loading branch information
billyc committed Oct 24, 2024
1 parent 684ee07 commit b0e888f
Show file tree
Hide file tree
Showing 19 changed files with 148 additions and 107 deletions.
52 changes: 38 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@math.gl/polygon": "^3.2.2",
"@simwrapper/papaparse": "^5.3.2-2",
"blob-util": "^2.0.2",
"buefy": "^0.9.29",
"bulma": "^1.0.0",
"convert-seconds": "^1.0.1",
"crossfilter2": "^1.5.4",
Expand All @@ -35,7 +36,7 @@
"font-awesome": "^4.7.0",
"js-coroutines": "^2.4.6",
"markdown-it": "^12.2.0",
"mathjs": "^10.0.0",
"mathjs": "^13.2.0",
"medium-zoom": "^1.0.5",
"micromatch": "^4.0.8",
"moment": "^2.24.0",
Expand All @@ -56,7 +57,7 @@
"vue-js-toggle-button": "^1.3.3",
"vue-router": "^3.5.3",
"vue-slide-bar": "^1.2.0",
"vue-slider-component": "^3.1.2",
"vue-slider-component": "^3.2.24",
"vuera": "^0.2.7",
"vuex": "^3.1.3",
"yaml": "^1.7.2",
Expand Down
65 changes: 34 additions & 31 deletions src/components/PlaybackControls.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template lang="pug">
.my-vue-component
vue-slider.slider(v-model="sliderValue"
b-slider.slider(v-model="sliderValue"
v-bind="sliderOptions"
@dragging="dragging"
@drag-start="dragStart"
@drag-end="dragEnd")
@dragstart="dragStart"
@dragend="dragEnd")

.buttons
.playpause(@click='toggleSimulation')
Expand All @@ -17,19 +17,36 @@
import { defineComponent } from 'vue'
import type { PropType } from 'vue'
import VueSlider from 'vue-slider-component'
import * as timeConvert from 'convert-seconds'
import timeConvert from 'convert-seconds'
import store from '@/store'
import EventBus from '@/EventBus.vue'
const maxSliderVal = 100000.0
const getSecondsFromSlider = (oneToTenThousand: number) => {
let seconds = (oneToTenThousand / maxSliderVal) * 86400
if (seconds === 86400) seconds = 86400 - 1
return seconds
}
const convertSecondsToClockTimeMinutes = (index: number) => {
const seconds = getSecondsFromSlider(index)
try {
const hms = timeConvert(seconds)
const minutes = ('00' + hms.minutes).slice(-2)
return `${hms.hours}:${minutes}`
} catch (e) {
return '00:00'
}
}
export default defineComponent({
name: 'PlaybackControls',
components: { VueSlider },
components: {},
data: () => {
const maxSliderVal = 100000.0
return {
state: store.state,
sliderValue: 0,
Expand All @@ -42,24 +59,17 @@ export default defineComponent({
duration: 0,
lazy: true,
tooltip: 'active',
size: 'is-large',
'tooltip-always': true,
'tooltip-placement': 'top',
} as any,
'custom-formatter': convertSecondsToClockTimeMinutes,
// (v: number) => {
// return convertSecondsToClockTimeMinutes(v)
// },
},
}
},
methods: {
convertSecondsToClockTimeMinutes(index: number) {
const seconds = this.getSecondsFromSlider(index)
try {
const hms = timeConvert(seconds)
const minutes = ('00' + hms.minutes).slice(-2)
return `${hms.hours}:${minutes}`
} catch (e) {
return '00:00'
}
},
onKeyPressed(ev: KeyboardEvent) {
if (ev.code === 'Space') this.toggleSimulation()
},
Expand All @@ -79,18 +89,12 @@ export default defineComponent({
},
dragging(value: any) {
EventBus.$emit(EventBus.DRAG, this.getSecondsFromSlider(value))
},
getSecondsFromSlider(oneToTenThousand: number) {
let seconds = (oneToTenThousand / this.maxSliderVal) * 86400
if (seconds === 86400) seconds = 86400 - 1
return seconds
EventBus.$emit(EventBus.DRAG, getSecondsFromSlider(value))
},
},
mounted() {
this.sliderOptions['tooltip-formatter'] = this.convertSecondsToClockTimeMinutes
// this.sliderOptions['tooltip-formatter'] = convertSecondsToClockTimeMinutes
EventBus.$on(EventBus.SIMULATION_PERCENT, (time: number) => {
this.sliderValue = Math.floor(this.maxSliderVal * time)
Expand All @@ -106,7 +110,6 @@ export default defineComponent({
</script>

<style scoped lang="scss">
@use '~/vue-slider-component/theme/antd.css' as *;
@use '@/styles.scss' as *;
.my-vue-component {
Expand Down
12 changes: 8 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@ import App from '@/App.vue'
import router from '@/router'
import store from '@/store'

import Buefy from 'buefy'
import 'buefy/dist/buefy.min.css'

Vue.config.productionTip = false

Vue.use(VueI18n)
Vue.use(Buefy)

console.log('here')
// locale: we only support EN and DE
const locale = localStorage.getItem('default-locale')
? '' + localStorage.getItem('default-locale')
: // @ts-ignore
// @ts-ignore
(navigator.language || navigator.userLanguage).startsWith('de')
? 'de'
: 'en'
// @ts-ignore
(navigator.language || navigator.userLanguage).startsWith('de')
? 'de'
: 'en'

const i18n = new VueI18n({
locale,
Expand Down
1 change: 0 additions & 1 deletion src/runs/v1/V1.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import type { PropType } from 'vue'
import YAML from 'yaml'
import Papa from '@simwrapper/papaparse'
import { Component, Vue } from 'vue-property-decorator'
import SectionViewer from './ChartSelector.vue'
import md from 'markdown-it'
Expand Down
1 change: 0 additions & 1 deletion src/runs/v3/V3.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

<script lang="ts">
import { defineComponent } from 'vue'
import type { PropType } from 'vue'
import store from '@/store'
import AnimationView from '@/runs/v3/AnimationView.vue'
Expand Down
1 change: 0 additions & 1 deletion src/runs/v6/ChartSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@

<script lang="ts">
// ###########################################################################
import { Component, Vue, Prop, Watch } from 'vue-property-decorator'
import Papa from '@simwrapper/papaparse'
import VuePlotly from '@/components/VuePlotly.vue'
import ZipLoader from 'zip-loader'
Expand Down
1 change: 0 additions & 1 deletion src/shims-vue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ declare module 'react-toggle'
declare module 'read-blob'
declare module 'vue-slide-bar'
declare module 'vue-table-component'
declare module 'vue-slider-component'
declare module 'vue-video-player'
declare module 'vuera'
declare module 'zip-loader'
Expand Down
30 changes: 25 additions & 5 deletions src/views/Imprint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,33 @@
</template>

<script lang="ts">
import { Vue, Component, Watch, Prop } from 'vue-property-decorator'
import { defineComponent } from 'vue'
import Colophon from '@/components/Colophon.vue'
@Component({ components: { Colophon }, props: {} })
export default class VueComponent extends Vue {
private imprint = require('@/assets/imprint.en.md')
}
import imprint from '@/assets/imprint.en.md?raw'
import Markdown from 'markdown-it'
const html = new Markdown({
html: true,
linkify: true,
typographer: true,
}).render(imprint)
export default defineComponent({
name: 'Imprint',
components: { Colophon },
props: {},
data() {
return {
imprint: html,
}
},
methods: {},
})
</script>

<style scoped lang="scss">
Expand Down
1 change: 0 additions & 1 deletion src/views/MobilityPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ const i18n = {
},
}
import { Vue, Component, Watch, Prop } from 'vue-property-decorator'
import { Route } from 'vue-router'
import MarkdownIt from 'markdown-it'
import Papaparse from '@simwrapper/papaparse'
Expand Down
1 change: 0 additions & 1 deletion src/views/RCalculatorNew.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ const i18n = {
},
}
import { Vue, Component, Watch, Prop } from 'vue-property-decorator'
import YAML from 'yaml'
import { Route } from 'vue-router'
import MarkdownIt from 'markdown-it'
Expand Down
1 change: 0 additions & 1 deletion src/views/v1/HeatMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ vue-plotly(v-if="!isResizing" :data="dataMatrix" :layout="layout" :options="opti
</template>

<script lang="ts">
import { Vue, Component, Watch, Prop } from 'vue-property-decorator'
import VuePlotly from '@/components/VuePlotly.vue'
import { log, transpose } from 'mathjs'
Expand Down
1 change: 0 additions & 1 deletion src/views/v1/MutationsPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
</template>

<script lang="ts">
import { Vue, Component, Watch, Prop } from 'vue-property-decorator'
import VuePlotly from '@/components/VuePlotly.vue'
import Papa from '@simwrapper/papaparse'
import { PUBLIC_SVN } from '@/Globals'
Expand Down
Loading

0 comments on commit b0e888f

Please sign in to comment.