Fix: moreLoading

This commit is contained in:
cutls 2019-11-16 21:29:11 +09:00
parent b9d562d8f0
commit fe32723ad5
2 changed files with 39 additions and 31 deletions

View File

@ -183,7 +183,7 @@ async function mixmore(tlid, type) {
.attr('unique-id') .attr('unique-id')
let startLocal = 'https://' + domain + '/api/v1/timelines/public?local=true&max_id=' + sid let startLocal = 'https://' + domain + '/api/v1/timelines/public?local=true&max_id=' + sid
let local = await getTL(startLocal, acct_id) let local = await getTL(startLocal, acct_id)
let startHome = 'https://' + domain + '/api/v1/timelines/home&max_id=' + sid let startHome = 'https://' + domain + '/api/v1/timelines/home?max_id=' + sid
let home = await getTL(startHome, acct_id) let home = await getTL(startHome, acct_id)
let concated = _.concat(local, home) let concated = _.concat(local, home)
let uniqued = _.uniqBy(concated, 'id') let uniqued = _.uniqBy(concated, 'id')

View File

@ -1,62 +1,70 @@
//スクロールで続きを読む //スクロールで続きを読む
function scrollevent() { function scrollevent() {
$(".tl-box").scroll(function () { $('.tl-box').scroll(function() {
scrollck(); scrollck()
}); })
} }
scrollevent(); scrollevent()
function scrollck() { function scrollck() {
$(".tl-box").each(function (i, elem) { $('.tl-box').each(function(i, elem) {
var tlid = $(this).attr('tlid'); var tlid = $(this).attr('tlid')
var len = $('#timeline_' + tlid + ' .cvo').length
//一番上ならためていた新しいトゥートを表示ないしtealなら未読管理モード //一番上ならためていた新しいトゥートを表示ないしtealなら未読管理モード
if ($(this).scrollTop() === 0) { if ($(this).scrollTop() === 0) {
if (!$("#unread_" + tlid + " .material-icons").hasClass("teal-text")) { if (!$('#unread_' + tlid + ' .material-icons').hasClass('teal-text')) {
var pool = localStorage.getItem("pool_" + tlid); var pool = localStorage.getItem('pool_' + tlid)
if (pool) { if (pool) {
$("#timeline_" + tlid).prepend(pool); $('#timeline_' + tlid).prepend(pool)
jQuery("time.timeago").timeago(); jQuery('time.timeago').timeago()
localStorage.removeItem("pool_" + tlid); localStorage.removeItem('pool_' + tlid)
} }
} else { } else {
ueload(tlid) ueload(tlid)
} }
//自動リフレッシュ //自動リフレッシュ
if ($("#timeline_" + tlid + " .cvo").length > 30) { if (len > 30) {
for (var i = 30; i < $("#timeline_" + tlid + " .cvo").length; i++) { for (var i = 30; i < $('#timeline_' + tlid + ' .cvo').length; i++) {
$("#timeline_" + tlid + " .cvo").eq(i).remove(); $('#timeline_' + tlid + ' .cvo')
.eq(i)
.remove()
} }
} }
} }
//続きを読むトリガー //続きを読むトリガー
var scrt = $(this).find(".tl").height() - $(window).height(); var scrt =
var scr = $(this).scrollTop(); $(this)
if (scr > scrt) { .find('.tl')
console.log("kicked more loading:" + tlid); .height() - $(window).height()
moreload('', tlid); var scr = $(this).scrollTop()
if (scr > scrt && scrt > 0) {
console.log('kicked more loading:' + tlid)
moreload('', tlid)
} }
}); })
} }
function goTop(id) { function goTop(id) {
if ($("#unread_" + id + " .material-icons").hasClass("teal-text")) { if ($('#unread_' + id + ' .material-icons').hasClass('teal-text')) {
$("#unread_" + id + " .material-icons").removeClass("teal-text") $('#unread_' + id + ' .material-icons').removeClass('teal-text')
var multi = localStorage.getItem("column") var multi = localStorage.getItem('column')
var obj = JSON.parse(multi) var obj = JSON.parse(multi)
var acct_id = obj[id * 1].domain var acct_id = obj[id * 1].domain
var type = obj[id * 1].type var type = obj[id * 1].type
console.log(id, type) console.log(id, type)
columnReload(id, type) columnReload(id, type)
} }
if ($("#timeline_box_" + id + "_box .tl-box").scrollTop() > 500) { if ($('#timeline_box_' + id + '_box .tl-box').scrollTop() > 500) {
$("#timeline_box_" + id + "_box .tl-box").scrollTop(500) $('#timeline_box_' + id + '_box .tl-box').scrollTop(500)
} }
$("#timeline_box_" + id + "_box .tl-box").animate({ scrollTop: 0 }); $('#timeline_box_' + id + '_box .tl-box').animate({ scrollTop: 0 })
} }
function goColumn(key) { function goColumn(key) {
$("#sort-box").addClass("hide"); $('#sort-box').addClass('hide')
$("#sort-box").removeClass("show"); $('#sort-box').removeClass('show')
if ($('[tlid=' + key + ']').length) { if ($('[tlid=' + key + ']').length) {
$("#timeline-container").animate({ scrollLeft: $("#timeline-container").scrollLeft() + $('[tlid=' + key + ']').offset().left }); $('#timeline-container').animate({
scrollLeft: $('#timeline-container').scrollLeft() + $('[tlid=' + key + ']').offset().left
})
} }
} }