mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
577a749e12
no issue - followed the migration guide to switch to from lifecycle hooks to single `modify()` method - https://togithub.com/ember-modifier/ember-modifier/blob/master/MIGRATIONS.md - forced resolution of `ember-in-viewport@4.0.2` to avoid older version of `ember-modifier` being pulled in through `ember-infinity`
14 lines
522 B
JavaScript
14 lines
522 B
JavaScript
import getScrollParent from 'ghost-admin/utils/get-scroll-parent';
|
|
import {modifier} from 'ember-modifier';
|
|
|
|
export default modifier((element, positional, {shouldScroll = true}) => {
|
|
if (shouldScroll) {
|
|
// setTimeout needed to ensure layout has finished and we have accurate
|
|
setTimeout(() => {
|
|
const scrollParent = getScrollParent(element);
|
|
const y = element.offsetTop;
|
|
scrollParent.scrollTo({top: y, behavior: 'smooth'});
|
|
}, 200);
|
|
}
|
|
}, {eager: false});
|