무한스크롤

iikasam·2022년 7월 13일
0
$(function () {
    showGradient();
    $('.scrollwrap').on('scroll', showGradient);
});

function showGradient2() {
    const scrollWidth = Math.ceil($('.list_box').scrollLeft() + $('.list_box').width());
    const totalWidth = $('.list').width();
    let test = $(this).children('.list')[0]
    let test2 = $(this).find('li').get().length / 2;
    
    if ($('.list_box').scrollLeft() == 0) {
        $('.scrolllo2').text('스크롤 처음입니다.');
    } else if (scrollWidth >= totalWidth) {
        $('.scrolllo2').text('스크롤 끝입니다.');
        $(this).find('li').clone().appendTo($(this).children('.list'));
    } else if (scrollWidth > 3000) {
        $('.scrolllo2').text('스크롤 중간입니다.');
        console.log(test)
        $(this).children('.list').replaceWith(test)
        console.log($(this).children('.list'));
    }
}
profile
묵묵히, 꾸준히,

0개의 댓글