appointments.js
1 day ago
attendees.js
1 day ago
colorManipulation.js
1 day ago
customer.js
1 day ago
date.js
1 day ago
defaultCustomize.js
1 day ago
employee.js
1 day ago
events.js
1 day ago
formFieldsTemplates.js
1 day ago
formatting.js
1 day ago
helper.js
1 day ago
image.js
1 day ago
integrationApple.js
1 day ago
integrationGoogle.js
1 day ago
integrationOutlook.js
1 day ago
integrationStripe.js
1 day ago
integrationZoom.js
1 day ago
licence.js
1 day ago
phone.js
1 day ago
pricing.js
1 day ago
recurring.js
1 day ago
responsive.js
1 day ago
scrollElements.js
1 day ago
settings.js
1 day ago
translationsElementPlus.js
1 day ago
utilHeaderHeight.js
1 day ago
scrollElements.js
48 lines
| 1 | function useScrollTo( |
| 2 | elementContainer, |
| 3 | elem, |
| 4 | fromTop, |
| 5 | duration, |
| 6 | nested = { |
| 7 | inCollapse: false, |
| 8 | }, |
| 9 | ) { |
| 10 | let start = elementContainer.scrollTop, |
| 11 | containerTop = elementContainer.offsetTop, |
| 12 | to = elem.offsetTop, |
| 13 | change = to - (start + containerTop + fromTop), |
| 14 | currentTime = 0, |
| 15 | increment = 20 |
| 16 | |
| 17 | if (nested.inCollapse) { |
| 18 | change = |
| 19 | to + |
| 20 | elem.offsetParent.offsetTop + |
| 21 | elem.offsetParent.offsetParent.offsetTop + |
| 22 | elem.offsetParent.offsetParent.offsetParent.offsetTop - |
| 23 | (start + containerTop + fromTop) |
| 24 | } |
| 25 | |
| 26 | let animateScroll = function () { |
| 27 | currentTime += increment |
| 28 | elementContainer.scrollTop = Math.easeInOutQuad(currentTime, start, change, duration) |
| 29 | if (currentTime < duration) { |
| 30 | setTimeout(animateScroll, increment) |
| 31 | } |
| 32 | } |
| 33 | animateScroll() |
| 34 | } |
| 35 | |
| 36 | //t = current time |
| 37 | //b = start value |
| 38 | //c = change in value |
| 39 | //d = duration |
| 40 | Math.easeInOutQuad = function (t, b, c, d) { |
| 41 | t /= d / 2 |
| 42 | if (t < 1) return (c / 2) * t * t + b |
| 43 | t-- |
| 44 | return (-c / 2) * (t * (t - 2) - 1) + b |
| 45 | } |
| 46 | |
| 47 | export { useScrollTo } |
| 48 |