Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js animate scroll to the top of the page

// Experimental: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView#Browser_compatibility
document.body.scrollIntoView({behavior: 'smooth', block: 'start'});
Comment

js animate scroll to the top of the page

function scrollTo(element, to, duration) {
    if (duration <= 0) return;
    var difference = to - element.scrollTop;
    var perTick = difference / duration * 10;

    setTimeout(function() {
        element.scrollTop = element.scrollTop + perTick;
        if (element.scrollTop === to) return;
        scrollTo(element, to, duration - 10);
    }, 10);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: check data in formData 
Javascript :: get all rooms socket.io 
Javascript :: console.log regex 
Javascript :: js style remove property 
Javascript :: nextauth dynamic redirect after login 
Javascript :: create random aleatory token javascript 
Javascript :: javascript element edit value 
Javascript :: play a sound wiith js 
Javascript :: jquery bind function to multiple events 
Javascript :: jquery datatable get data array 
Javascript :: react native metro api level 30 
Javascript :: js create script tag request 
Javascript :: package json accept any version 
Javascript :: NotYetImplemented ng2-chart angular 2 
Javascript :: check radio button is checked jquery 
Javascript :: how to get nth fibonacci javascript 
Javascript :: ejs / javascript check if array/object exists and is not empty 
Javascript :: javascript onclick 
Javascript :: how to clone a object in javascript angular 
Javascript :: nodejs btoa 
Javascript :: save things javascript 
Javascript :: sort and split js alefbethic 
Javascript :: current time in javascript 
Javascript :: get keys objet javascript 
Javascript :: jquery if input has empty white space 
Javascript :: load js after ajax 
Javascript :: Setting object properties in C# from Javascript code 
Javascript :: invoke lambda nodejs 
Javascript :: remove file from input type file jquery 
Javascript :: add readonly attribute jquery 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =