Popravljeno skrolanje sekcij (urejanje, dodajanje pojma)

pull/54/head
Jurij Podgoršek 2024-03-05 22:48:42 +01:00
parent ce05befebe
commit ba4ec35410
6 changed files with 49 additions and 24 deletions

View File

@ -83,6 +83,7 @@
background: none; background: none;
text-decoration: underline; text-decoration: underline;
width: fit-content; width: fit-content;
z-index: 100;
} }
footer { footer {

View File

@ -3,6 +3,8 @@
import { stripHtml } from 'string-strip-html' import { stripHtml } from 'string-strip-html'
const { etherFetch } = useEtherpadApi() const { etherFetch } = useEtherpadApi()
const { poskrolaj } = useUi()
const store = usePojmiStore() const store = usePojmiStore()
const route = useRoute() const route = useRoute()
@ -40,16 +42,15 @@ onMounted(() => {
// Link na editiranje pojma? Poskrolaj nanj + odpri editiranje // Link na editiranje pojma? Poskrolaj nanj + odpri editiranje
if (route.params.guid === revisionId.value) { if (route.params.guid === revisionId.value) {
urejanje.value = true urejanje.value = true
setTimeout(() => obrazec.value.scrollIntoView({ behavior: 'smooth' }), 50)
} else { } else {
// Sicer samo poskrolaj na pojem // Sicer samo poskrolaj na pojem
setTimeout(() => { poskrolaj(container.value.parentNode)
const sekcija = container.value.parentNode }
console.log('skrolam?', sekcija) })
if (sekcija) {
sekcija.scrollIntoView({ behavior: 'smooth' }) onUpdated(() => {
} if (route.params.guid === revisionId.value) {
}, 50) poskrolaj(obrazec.value)
} }
}) })
@ -62,11 +63,13 @@ onMounted(() => {
<h2>{{ naslov }}</h2> <h2>{{ naslov }}</h2>
<div class="tekst" v-html="pojem.tekst" /> <div class="tekst" v-html="pojem.tekst" />
</div> </div>
<PojemForm v-if="urejanje" <div class="obrazec" ref="obrazec">
ref="obrazec" <PojemForm v-if="urejanje"
:revisionId="revisionId" ref="obrazec"
:pojem="pojem" :revisionId="revisionId"
:onZapri="() => { urejanje = false; store.naloziPojme() }" /> :pojem="pojem"
:onZapri="() => { urejanje = false; store.naloziPojme() }" />
</div>
</section> </section>
</template> </template>
@ -87,9 +90,12 @@ onMounted(() => {
} }
form.pojem { form.pojem {
width: 100%;
}
.obrazec {
width: calc(50% - 32px); width: calc(50% - 32px);
margin-left: 32px; margin-left: 32px;
gap: 1rem;
float: right; float: right;
} }
@ -106,8 +112,12 @@ onMounted(() => {
width: 100%; width: 100%;
} }
form.pojem { .obrazec {
width: 100%;
margin-left: 0; margin-left: 0;
}
form.pojem {
min-height: 70vh; min-height: 70vh;
width: 100%; width: 100%;
margin-left: 0; margin-left: 0;

View File

@ -78,6 +78,10 @@ const etherNalozen = ev => {
</template> </template>
<style> <style>
form {
gap: 1rem;
}
.etherpad-textarea { .etherpad-textarea {
width: 100%; width: 100%;
flex-grow: 1; flex-grow: 1;

View File

@ -0,0 +1,12 @@
/* uporabne zadeve za vmesnik */
export const useUi = () => ({
poskrolaj: (sekcija, timeout = 50) => {
setTimeout(() => {
console.log('UI SKROL!', sekcija)
if (sekcija && sekcija.scrollIntoView) {
sekcija.scrollIntoView({ behavior: 'smooth' })
}
}, timeout)
}
})

View File

@ -1,8 +1,9 @@
<script setup="setup"> <script setup="setup">
const { getRandomUUID } = useCrypto() const { getRandomUUID } = useCrypto()
const { etherpadApiUrl } = useEtherpadApi() const { etherpadApiUrl } = useEtherpadApi()
const { poskrolaj } = useUi()
const route = useRoute() const route = useRoute()
const revisionId = ref(null) const revisionId = ref(null)
@ -18,11 +19,7 @@ const resp = await $fetch(`${etherpadApiUrl}/createPad?padID=${padId}`)
const onZapri = () => { navigateTo('/manifest#skrol') } const onZapri = () => { navigateTo('/manifest#skrol') }
onMounted(() => { onMounted(() => {
setTimeout(() => { poskrolaj(obrazec.value)
console.log('element?', obrazec.value)
debugger
obrazec.value.scrollIntoView({ behavior: 'smooth' })
}, 50)
}) })
</script> </script>

View File

@ -1,15 +1,16 @@
<script setup="setup"> <script setup="setup">
const store = usePojmiStore() const store = usePojmiStore()
const { poskrolaj } = useUi()
await store.naloziPojme() await store.naloziPojme()
const navodila = ref(null) const navodila = ref(null)
onMounted(() => { onMounted(() => {
if (location && location.hash == '#skrol') { if (location && location.hash == '#skrol') {
setTimeout(() => { poskrolaj(navodila.value)
navodila.value.scrollIntoView({ behavior: 'smooth' })
}, 50)
} }
}) })