FIX: correctly hides timeline scroller for short posts (#9581)
* FIX: correctly hides timeline scroller for short posts * fix linting
This commit is contained in:
parent
7ccfc73edb
commit
db337b10ee
|
@ -1,5 +1,5 @@
|
|||
import Mixin from "@ember/object/mixin";
|
||||
import { debounce } from "@ember/runloop";
|
||||
import { later, debounce } from "@ember/runloop";
|
||||
|
||||
const helper = {
|
||||
offset() {
|
||||
|
@ -32,7 +32,8 @@ export default Mixin.create({
|
|||
$(window).bind("scroll.discourse-dock", this.queueDockCheck);
|
||||
$(document).bind("touchmove.discourse-dock", this.queueDockCheck);
|
||||
|
||||
this.dockCheck(helper);
|
||||
// dockCheck might happen too early on full page refresh
|
||||
later(this, this.safeDockCheck, 50);
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
|
|
|
@ -518,32 +518,46 @@ export default createWidget("topic-timeline", {
|
|||
|
||||
result.push(this.attach("timeline-controls", attrs));
|
||||
|
||||
const bottomAge = relativeAge(new Date(topic.last_posted_at), {
|
||||
addAgo: true,
|
||||
defaultFormat: timelineDate
|
||||
});
|
||||
let scroller = [
|
||||
h(
|
||||
"div.timeline-date-wrapper",
|
||||
this.attach("link", {
|
||||
className: "start-date",
|
||||
rawLabel: timelineDate(createdAt),
|
||||
action: "jumpTop"
|
||||
})
|
||||
),
|
||||
this.attach("timeline-scrollarea", attrs),
|
||||
h(
|
||||
"div.timeline-date-wrapper",
|
||||
this.attach("link", {
|
||||
className: "now-date",
|
||||
rawLabel: bottomAge,
|
||||
action: "jumpBottom"
|
||||
})
|
||||
)
|
||||
];
|
||||
let displayTimeLineScrollArea = true;
|
||||
if (!attrs.mobileView) {
|
||||
const streamLength = attrs.topic.get("postStream.stream.length");
|
||||
|
||||
result.push(h("div.timeline-scrollarea-wrapper", scroller));
|
||||
result.push(this.attach("timeline-footer-controls", attrs));
|
||||
if (streamLength < 2) {
|
||||
const postsWrapper = document.querySelector(".posts-wrapper");
|
||||
if (postsWrapper && postsWrapper.offsetHeight < 1000) {
|
||||
displayTimeLineScrollArea = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (displayTimeLineScrollArea) {
|
||||
const bottomAge = relativeAge(new Date(topic.last_posted_at), {
|
||||
addAgo: true,
|
||||
defaultFormat: timelineDate
|
||||
});
|
||||
let scroller = [
|
||||
h(
|
||||
"div.timeline-date-wrapper",
|
||||
this.attach("link", {
|
||||
className: "start-date",
|
||||
rawLabel: timelineDate(createdAt),
|
||||
action: "jumpTop"
|
||||
})
|
||||
),
|
||||
this.attach("timeline-scrollarea", attrs),
|
||||
h(
|
||||
"div.timeline-date-wrapper",
|
||||
this.attach("link", {
|
||||
className: "now-date",
|
||||
rawLabel: bottomAge,
|
||||
action: "jumpBottom"
|
||||
})
|
||||
)
|
||||
];
|
||||
|
||||
result.push(h("div.timeline-scrollarea-wrapper", scroller));
|
||||
result.push(this.attach("timeline-footer-controls", attrs));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue