2021-09-08 15:00:24 +03:00
|
|
|
import getScrollParent from 'ghost-admin/utils/get-scroll-parent';
|
|
|
|
import {modifier} from 'ember-modifier';
|
|
|
|
|
2022-11-11 14:53:53 +03:00
|
|
|
export default modifier((element, positional, {when = true}) => {
|
|
|
|
if (when) {
|
|
|
|
// setTimeout needed to ensure layout has finished and we have accurate positioning
|
2021-09-08 15:00:24 +03:00
|
|
|
setTimeout(() => {
|
|
|
|
const scrollParent = getScrollParent(element);
|
|
|
|
const y = element.offsetTop;
|
|
|
|
scrollParent.scrollTo({top: y, behavior: 'smooth'});
|
|
|
|
}, 200);
|
|
|
|
}
|
2022-08-02 11:23:43 +03:00
|
|
|
}, {eager: false});
|