I should point out that I have never had a career as a web developer.
My last thirty years of employment, before retirement, were spent as
a simple milkman and then a simple postman.
I started coding when I was given a p.c. about 18 years ago and
accidentally found, a little while later, the “View Source” button.
Intrigued, I joined many of the coding forums that were prolific back then.
Problem solving in those forums was my preferred method, and my main
reason, for learning how to code, as I firmly believed that it would help
stave off the onset of senile dementia.
I have never been comfortable with “javaScript”.
The little that I know, used to be referred to as DHTML.
Not really, as I have no interest in any problem which involves
working with frameworks.
I suppose you could say that I do not believe their code is poetry.
The default is right:1.25em but when the class .displayout is added to .classscrolltop it moves off screen to the right (right:-3.25em) and consquently when the class is removed it goes back to right:1.25em.
I know JQuery is not that great, but one should learn the core Javascript from the first principle, but I was just wondering how can we give the same effect through JQuery that @coothead sir has given through Vanilla JS.
I think the secret lies here →
if ($(this).scrollTop() >= 50) { // If page is scrolled more than 50px
$('#scrolltop').fadeIn(200); // Fade in the arrow
} else {
$('#scrolltop').fadeOut(200); // Else fade out the arrow
}
I tried some animation property variations like this →
if ($(this).scrollTop() >= 50) { // If page is scrolled more than 50px
$('#scrolltop').animate({"left":"0px", "slow"); // Fade in the arrow
} else {
$('#scrolltop').animate({"right":"0px", "slow");; // Else fade out the arrow
}
But I could not make it work(arrow coming appear from the right and vice versa).