adjust auto scroll

pull/349/head
Pete Matsyburka 1 year ago
parent e0ddf97771
commit 9193511d5f

@ -75,6 +75,11 @@ export default {
required: false, required: false,
default: true default: true
}, },
scrollEl: {
type: Object,
required: false,
default: null
},
currentStep: { currentStep: {
type: Array, type: Array,
required: false, required: false,
@ -109,7 +114,12 @@ export default {
if (container.style.overflow === 'hidden') { if (container.style.overflow === 'hidden') {
this.scrollInContainer(areaRef.$el) this.scrollInContainer(areaRef.$el)
} else { } else {
areaRef.$refs.scrollToElem.scrollIntoView({ behavior: 'smooth', block: 'start' }) const targetRect = areaRef.$refs.scrollToElem.getBoundingClientRect()
const root = this.$root.$el?.parentNode?.classList?.contains('ds') ? this.$root.$el : document.body
const rootRect = root.getBoundingClientRect()
const scrollEl = this.scrollEl || window
scrollEl.scrollTo({ top: targetRect.top - rootRect.top, behavior: 'smooth' })
} }
return true return true
@ -128,7 +138,7 @@ export default {
const targetTopRelativeToBox = targetRect.top - boxRect.top const targetTopRelativeToBox = targetRect.top - boxRect.top
scrollbox.scrollTop = targetTopRelativeToBox - container.offsetHeight + formContainer.offsetHeight + target.offsetHeight + padding scrollbox.scrollTo({ top: targetTopRelativeToBox - container.offsetHeight + formContainer.offsetHeight + target.offsetHeight + padding, behavior: 'smooth' })
}, },
setAreaRef (el) { setAreaRef (el) {
if (el) { if (el) {

@ -4,6 +4,7 @@
:steps="stepFields" :steps="stepFields"
:values="values" :values="values"
:with-field-placeholder="withFieldPlaceholder" :with-field-placeholder="withFieldPlaceholder"
:scroll-el="scrollEl"
:attachments-index="attachmentsIndex" :attachments-index="attachmentsIndex"
:with-label="!isAnonymousChecboxes && showFieldNames" :with-label="!isAnonymousChecboxes && showFieldNames"
:current-step="currentStepFields" :current-step="currentStepFields"
@ -554,6 +555,11 @@ export default {
required: false, required: false,
default: false default: false
}, },
scrollEl: {
type: Object,
required: false,
default: null
},
onComplete: { onComplete: {
type: Function, type: Function,
required: false, required: false,

Loading…
Cancel
Save