DEV: Allow overiding calculation of top offset for card contents base (#11254)

This commit is contained in:
Martin Brennan 2020-11-17 11:05:59 +10:00 committed by GitHub
parent de174ef0c4
commit a9b20fa827
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,7 @@ import afterTransition from "discourse/lib/after-transition";
import DiscourseURL from "discourse/lib/url";
import Mixin from "@ember/object/mixin";
import { escapeExpression } from "discourse/lib/utilities";
import outletHeights from "discourse/lib/header-outlet-height";
import headerOutletHeights from "discourse/lib/header-outlet-height";
import { inject as service } from "@ember/service";
export default Mixin.create({
@ -212,7 +212,10 @@ export default Mixin.create({
}
}
position.top -= $("#main-outlet").offset().top - outletHeights();
position.top -= this._calculateTopOffset(
$("#main-outlet").offset(),
headerOutletHeights()
);
if (isFixed) {
position.top -= $("html").scrollTop();
//if content is fixed and will be cut off on the bottom, display it above...
@ -261,6 +264,13 @@ export default Mixin.create({
});
},
// some plugins/themes modify the page layout and may
// need to override this calculation for the card to
// position correctly
_calculateTopOffset(mainOutletOffset, outletHeights) {
return mainOutletOffset.top - outletHeights;
},
_hide() {
if (!this.visible) {
$(this.element).css({ left: -9999, top: -9999 });