mirror of
https://github.com/discourse/discourse.git
synced 2025-06-08 00:27:32 +08:00
FIX: correctly hides timeline scroller for short posts (#9581)
* FIX: correctly hides timeline scroller for short posts * fix linting
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
import Mixin from "@ember/object/mixin";
|
import Mixin from "@ember/object/mixin";
|
||||||
import { debounce } from "@ember/runloop";
|
import { later, debounce } from "@ember/runloop";
|
||||||
|
|
||||||
const helper = {
|
const helper = {
|
||||||
offset() {
|
offset() {
|
||||||
@ -32,7 +32,8 @@ export default Mixin.create({
|
|||||||
$(window).bind("scroll.discourse-dock", this.queueDockCheck);
|
$(window).bind("scroll.discourse-dock", this.queueDockCheck);
|
||||||
$(document).bind("touchmove.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() {
|
willDestroyElement() {
|
||||||
|
@ -518,6 +518,19 @@ export default createWidget("topic-timeline", {
|
|||||||
|
|
||||||
result.push(this.attach("timeline-controls", attrs));
|
result.push(this.attach("timeline-controls", attrs));
|
||||||
|
|
||||||
|
let displayTimeLineScrollArea = true;
|
||||||
|
if (!attrs.mobileView) {
|
||||||
|
const streamLength = attrs.topic.get("postStream.stream.length");
|
||||||
|
|
||||||
|
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), {
|
const bottomAge = relativeAge(new Date(topic.last_posted_at), {
|
||||||
addAgo: true,
|
addAgo: true,
|
||||||
defaultFormat: timelineDate
|
defaultFormat: timelineDate
|
||||||
@ -544,6 +557,7 @@ export default createWidget("topic-timeline", {
|
|||||||
|
|
||||||
result.push(h("div.timeline-scrollarea-wrapper", scroller));
|
result.push(h("div.timeline-scrollarea-wrapper", scroller));
|
||||||
result.push(this.attach("timeline-footer-controls", attrs));
|
result.push(this.attach("timeline-footer-controls", attrs));
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user