Ghost/ghost/admin/app/components/gh-canvas-header.js
Kevin Ansfield 99bfde4417 Converted <GhCanvasHeader> to glimmer component
no issue

- added `{{on-scroll}}` modifier to replace custom setup and teardown of event handlers inside the component
2022-05-25 10:07:11 +01:00

16 lines
546 B
JavaScript

import Component from '@glimmer/component';
import {action} from '@ember/object';
export default class GhCanvasHeader extends Component {
@action
onScroll(element, scrollContainer) {
if (this._isSticky && scrollContainer.scrollTop < 10) {
element.classList.remove('gh-canvas-header--sticky');
this._isSticky = false;
} else if (!this._isSticky && scrollContainer.scrollTop > 10) {
element.classList.add('gh-canvas-header--sticky');
this._isSticky = true;
}
}
}