thedesk/app/js/ui/scroll.js

71 lines
2.0 KiB
JavaScript
Raw Normal View History

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