Answers for "jquery on scroll element"

1

jquery on scroll

Syntax
Trigger the scroll event for the selected elements:
$(selector).scroll()

Attach a function to the scroll event:
$(selector).scroll(function)
Posted by: Guest on June-25-2020
0

angular scroll event on div chang width

<body style="overflow: scroll; height: 1000px;" onload="scrollDetect()">
    <div class="firstdiv" style="border:1px solid black; margin: 0 auto; width: 200px;height: 200px;">
    </div>

    <script>
        function scrollDetect() {
            let div = document.querySelector('.firstdiv')
            var lastScroll = 0;
            window.onscroll = function () {
                let currentScroll = document.documentElement.scrollTop; // Get Current Scroll Value
                if (currentScroll > 0 && lastScroll <= currentScroll) {
                    lastScroll = currentScroll;
                    div.style.width = '50%'
                    div.style.height = "50%";
                    div.style.background = "red";
                    div.style.position = "relative";
                    div.style.top = "0";
                    div.style.left = "0";
                } else {
                    lastScroll = currentScroll;
                    div.style.width = '200px'
                    div.style.height = '200px'
                }
            };
        }
    </script>
</body>
Posted by: Guest on December-03-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language