Headlines.renderAgain: scroll instantly to active article when going back to combined mode on the fly
This commit is contained in:
parent
b3e4f0188e
commit
e17c7e2fb4
|
@ -289,7 +289,7 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
},
|
},
|
||||||
cdmScrollToId: function (id, force, event) {
|
cdmScrollToId: function (id, force, event, immediate) {
|
||||||
const ctr = $("headlines-frame");
|
const ctr = $("headlines-frame");
|
||||||
const e = $("RROW-" + id);
|
const e = $("RROW-" + id);
|
||||||
const is_expanded = App.getInitParam("cdm_expanded");
|
const is_expanded = App.getInitParam("cdm_expanded");
|
||||||
|
@ -299,7 +299,7 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
if (force || is_expanded || e.offsetTop + e.offsetHeight > (ctr.scrollTop + ctr.offsetHeight) ||
|
if (force || is_expanded || e.offsetTop + e.offsetHeight > (ctr.scrollTop + ctr.offsetHeight) ||
|
||||||
e.offsetTop < ctr.scrollTop) {
|
e.offsetTop < ctr.scrollTop) {
|
||||||
|
|
||||||
if (event && event.repeat || !is_expanded) {
|
if (immediate || event && event.repeat || !is_expanded) {
|
||||||
ctr.addClassName("forbid-smooth-scroll");
|
ctr.addClassName("forbid-smooth-scroll");
|
||||||
window.clearTimeout(this._scroll_reset_timeout);
|
window.clearTimeout(this._scroll_reset_timeout);
|
||||||
|
|
||||||
|
|
|
@ -385,8 +385,22 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
objectById: function (id){
|
objectById: function (id){
|
||||||
return this.headlines[id];
|
return this.headlines[id];
|
||||||
},
|
},
|
||||||
|
setCommonClasses: function() {
|
||||||
|
$("headlines-frame").removeClassName("cdm");
|
||||||
|
$("headlines-frame").removeClassName("normal");
|
||||||
|
|
||||||
|
$("headlines-frame").addClassName(App.isCombinedMode() ? "cdm" : "normal");
|
||||||
|
|
||||||
|
// for floating title because it's placed outside of headlines-frame
|
||||||
|
$("main").removeClassName("expandable");
|
||||||
|
$("main").removeClassName("expanded");
|
||||||
|
|
||||||
|
if (App.isCombinedMode())
|
||||||
|
$("main").addClassName(App.getInitParam("cdm_expanded") ? " expanded" : " expandable");
|
||||||
|
},
|
||||||
renderAgain: function() {
|
renderAgain: function() {
|
||||||
// TODO: wrap headline elements into a knockoutjs model to prevent all this stuff
|
// TODO: wrap headline elements into a knockoutjs model to prevent all this stuff
|
||||||
|
Headlines.setCommonClasses();
|
||||||
|
|
||||||
$$("#headlines-frame > div[id*=RROW]").each((row) => {
|
$$("#headlines-frame > div[id*=RROW]").each((row) => {
|
||||||
const id = row.getAttribute("data-article-id");
|
const id = row.getAttribute("data-article-id");
|
||||||
|
@ -401,7 +415,7 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
new_row.addClassName("active");
|
new_row.addClassName("active");
|
||||||
|
|
||||||
if (App.isCombinedMode())
|
if (App.isCombinedMode())
|
||||||
Article.cdmScrollToId(id);
|
Article.cdmScrollToId(id, true, null, true);
|
||||||
else
|
else
|
||||||
Article.view(id);
|
Article.view(id);
|
||||||
}
|
}
|
||||||
|
@ -598,24 +612,12 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
Feeds.infscroll_disabled = parseInt(headlines_count) != 30;
|
Feeds.infscroll_disabled = parseInt(headlines_count) != 30;
|
||||||
console.log('infscroll_disabled=', Feeds.infscroll_disabled);
|
console.log('infscroll_disabled=', Feeds.infscroll_disabled);
|
||||||
|
|
||||||
// TODO: the below needs to be applied again when switching expanded/expandable on the fly
|
// also called in renderAgain() after view mode switch
|
||||||
// via hotkeys, not just on feed load
|
Headlines.setCommonClasses();
|
||||||
|
|
||||||
$("headlines-frame").removeClassName("cdm");
|
|
||||||
$("headlines-frame").removeClassName("normal");
|
|
||||||
|
|
||||||
$("headlines-frame").addClassName(App.isCombinedMode() ? "cdm" : "normal");
|
|
||||||
|
|
||||||
$("headlines-frame").setAttribute("is-vfeed",
|
$("headlines-frame").setAttribute("is-vfeed",
|
||||||
reply['headlines']['is_vfeed'] ? 1 : 0);
|
reply['headlines']['is_vfeed'] ? 1 : 0);
|
||||||
|
|
||||||
// for floating title because it's placed outside of headlines-frame
|
|
||||||
$("main").removeClassName("expandable");
|
|
||||||
$("main").removeClassName("expanded");
|
|
||||||
|
|
||||||
if (App.isCombinedMode())
|
|
||||||
$("main").addClassName(App.getInitParam("cdm_expanded") ? " expanded" : " expandable");
|
|
||||||
|
|
||||||
Article.setActive(0);
|
Article.setActive(0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue