팁과노하우

2025.03.01 23:54

아래로 당겨서 새로고침하기

웹뷰사용시 새로고침버튼이 없어서 새로고침하려면 불편하더라고요

네이버카페어플이나 기타 어플 같은경우 아래로 스크롤 하면 새로고침이 되는데

그방법입니다 저는 할줄 몰라서 돈주고 배웠습니다 고수님들은 금방하시겠지만

저처럼 초보자들에게 필요할까 해서 공유합니다


적용하고싶은 페이지에 아래내용 넣어주시면 됩니다

ace59879b3550ee3c337ecaa947f91c6_1740841227_8647.jpg
ace59879b3550ee3c337ecaa947f91c6_1740841228_8175.jpg
ace59879b3550ee3c337ecaa947f91c6_1740841229_5764.jpg
 

  <style>

      body {

font-family: 'Nanum Myeongjo', 'Apple SD Gothic Neo', '���� ����', serif;

    line-height: 1.6;

    background-color: #f8f9fa;

    color: #333;

    overscroll-behavior: contain;

ㅂ}

      </style>

<script src="https://unpkg.com/pulltorefreshjs" defer></script>

<script>

    document.addEventListener("DOMContentLoaded", () => {

        PullToRefresh.init({

            mainElement: '#scroll_container', // 새로고침이 작동할 스크롤 컨테이너

            onRefresh() {

                return new Promise((resolve, reject) => {

                    $.ajax({

                        url: window.location.href,

                        dataType: 'html',

                        success: function(data) {

                            // 임시 DOM 객체에 전체 HTML 삽입 후, #scroll_container의 내용 추출

                            var newContent = $('<div></div>').html(data).find('#scroll_container').html();

                            $('#scroll_container').html(newContent);

                            resolve();

                        },

                        error: function() {

                            resolve();

                        }

                    });

                });

            },

            instructionsPullToRefresh: '당겨서 새로고침',

            instructionsReleaseToRefresh: '놓으면 새로고침',

            instructionsRefreshing: '새로고침 중...'

        });


        const counters = document.querySelectorAll(".stats-value");


        counters.forEach(counter => {

            const updateCount = () => {

                const target = +counter.getAttribute("data-count");

                const count = +counter.innerText.replace(/,/g, '');


                const increment = target / 200; // 속도 조정


                if (count < target) {

                    counter.innerText = Math.ceil(count + increment).toLocaleString();

                    setTimeout(updateCount, 10);

                } else {

                    const suffix = counter.getAttribute("data-suffix") || "";

                    counter.innerText = target.toLocaleString() + suffix;

                }

            };


            updateCount();

        });

    });

</script> 



  • 공유링크 복사
    미니홈 쪽지 구독하기
    구독하고 알림받기

    댓글목록

    profile_image
    no_profile rainbow미니홈 1:1 대화하기  오래 전

    새로고침 기능으로 버튼보다는 팡야님이 소개해 준 방법이 요즘 더 좋은 방법같아요.
    공개해 주셔서 감사합니다.
    리빌드에도 해당 기능이 추가되면 좋을꺼 같네요.

    2025-03-02 13:23

    profile_image
    no_profile 재아미니홈 1:1 대화하기  오래 전

    추천 합니다~.

    2025-03-03 18:27

    profile_image
    기기괴괴미니홈 1:1 대화하기  오래 전

    와 좋은기능 같아요 요거는 어떻게 적용시켜야 하나요..?

    2025-03-07 21:53