Ghost/ghost/admin/app/components/gh-scroll-trigger.js
Kevin Ansfield b21e46aa39 Koenig - Keep MD card formatting toolbar visible when possible
refs https://github.com/TryGhost/Ghost/issues/9505
- use `{{gh-scroll-trigger}}` components at top and bottom of the markdown card when in edit mode so that styles can be applied to the `.editor-toolbar` element to keep the toolbar fixed at the bottom of the screen whilst scrolling
2018-04-24 13:10:20 +01:00

45 lines
995 B
JavaScript

import Component from '@ember/component';
import InViewportMixin from 'ember-in-viewport';
export default Component.extend(InViewportMixin, {
enter() {},
exit() {},
registerElement() {},
didInsertElement() {
let offset = this.get('triggerOffset') || {};
// if triggerOffset is a number we use it for all dimensions
if (typeof offset === 'number') {
offset = {
top: offset,
bottom: offset,
left: offset,
right: offset
};
}
this.set('viewportSpy', true);
this.set('viewportTolerance', {
top: offset.top,
bottom: offset.bottom,
left: offset.left,
right: offset.right
});
this._super(...arguments);
this.registerElement(this.element);
},
didEnterViewport() {
return this.enter();
},
didExitViewport() {
return this.exit();
}
});