thedesk/app/js/ui/scroll.js

57 lines
1.8 KiB
JavaScript
Raw Normal View History

2018-01-28 23:22:43 +11:00
//スクロールで続きを読む
function scrollevent() {
2019-05-19 17:39:30 +10:00
$(".tl-box").scroll(function () {
2018-01-28 23:22:43 +11:00
scrollck();
});
}
scrollevent();
function scrollck() {
2019-05-19 17:39:30 +10:00
$(".tl-box").each(function (i, elem) {
2018-01-28 23:22:43 +11:00
var tlid = $(this).attr('tlid');
2019-09-07 02:33:30 +10:00
//一番上ならためていた新しいトゥートを表示ないしtealなら未読管理モード
2019-03-08 05:19:26 +11:00
if ($(this).scrollTop() === 0) {
2019-09-07 02:33:30 +10:00
if (!$("#unread_" + tlid + " .material-icons").hasClass("teal-text")) {
var pool = localStorage.getItem("pool_" + tlid);
if (pool) {
$("#timeline_" + tlid).prepend(pool);
jQuery("time.timeago").timeago();
localStorage.removeItem("pool_" + tlid);
}
} else {
ueload(tlid)
2018-01-28 23:22:43 +11:00
}
2018-02-13 06:16:46 +11:00
//自動リフレッシュ
2019-05-19 17:39:30 +10:00
if ($("#timeline_" + tlid + " .cvo").length > 30) {
for (var i = 30; i < $("#timeline_" + tlid + " .cvo").length; i++) {
$("#timeline_" + tlid + " .cvo").eq(i).remove();
2018-02-13 06:16:46 +11:00
}
}
2018-01-28 23:22:43 +11:00
}
//続きを読むトリガー
2018-03-15 06:42:48 +11:00
var scrt = $(this).find(".tl").height() - $(window).height();
2018-01-28 23:22:43 +11:00
var scr = $(this).scrollTop();
if (scr > scrt) {
2019-05-19 17:39:30 +10:00
console.log("kicked more loading:" + tlid);
2018-01-28 23:22:43 +11:00
moreload('', tlid);
}
});
}
2018-01-31 03:43:01 +11:00
2019-05-19 17:39:30 +10:00
function goTop(id) {
2019-09-07 02:33:30 +10:00
if ($("#unread_" + id + " .material-icons").hasClass("teal-text")) {
$("#unread_" + id + " .material-icons").removeClass("teal-text")
columnReload(id)
}
2019-05-19 17:39:30 +10:00
if ($("#timeline_box_" + id + "_box .tl-box").scrollTop() > 500) {
$("#timeline_box_" + id + "_box .tl-box").scrollTop(500)
2018-02-25 02:59:53 +11:00
}
2019-05-19 17:39:30 +10:00
$("#timeline_box_" + id + "_box .tl-box").animate({ scrollTop: 0 });
2018-04-07 14:31:09 +10:00
}
2019-05-19 17:39:30 +10:00
function goColumn(key) {
2018-07-29 17:37:54 +10:00
$("#sort-box").addClass("hide");
$("#sort-box").removeClass("show");
2019-05-19 17:39:30 +10:00
if ($('[tlid=' + key + ']').length) {
$("#timeline-container").animate({ scrollLeft: $("#timeline-container").scrollLeft() + $('[tlid=' + key + ']').offset().left });
2018-04-07 14:31:09 +10:00
}
2018-01-31 03:43:01 +11:00
}