mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
99bfde4417
no issue - added `{{on-scroll}}` modifier to replace custom setup and teardown of event handlers inside the component
16 lines
546 B
JavaScript
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;
|
|
}
|
|
}
|
|
}
|