Create up-/down-slide or push effect with jQuery











up vote
0
down vote

favorite












I am replacing the src of an image when the user has scrolled to a certain point of the page with this jQuery code:



jQuery(function() {
var sticky = jQuery(".sticky-icon-white");
jQuery(window).scroll(function() {
var scroll = jQuery(window).scrollTop();

if (scroll >= 115) {
jQuery("#sticky-icon").attr("src", "https://dummyimage.com/100x100/000/fff");

} else {
jQuery("#sticky-icon").attr("src", "https://via.placeholder.com/100/");
sticky.removeClass('not-sticky-icon-white').addClass('sticky-icon-white');
}

if (scroll >= 300) {
sticky.removeClass('sticky-icon-white').addClass('not-sticky-icon-white');
} else {
sticky.removeClass('not-sticky-icon-white').addClass('sticky-icon-white');
}
});
});


This is my HTML:



<div class="sticky-icon-white">
<img id="sticky-icon" src="https://via.placeholder.com/100/">
</div>


The replacing is working fine but I want to apply a slide or push (not sure what to call it) animation on it. Like this one: https://gosimple.com (the leaf icon in the middle).



But I couldn't figure out how. Could someone help me to find a solution, please?



Here is a JSFiddle: http://jsfiddle.net/bzqad296/



Thanks in advance!



I have tried with slideUp(); or slideDown(); but it doesn't work.



EDIT:



In this image, you can see the effect. How the icon changes from white background, green leafs to green background, white leafs:
https://prnt.sc/lgwr3f










share|improve this question
























  • Can you tell more about the effects you want? In which of that site are you referring to?
    – SilentCoder
    Nov 11 at 1:37










  • @SilentCoder, check out the edit in my question please. Thanks.
    – TPA
    Nov 11 at 8:30















up vote
0
down vote

favorite












I am replacing the src of an image when the user has scrolled to a certain point of the page with this jQuery code:



jQuery(function() {
var sticky = jQuery(".sticky-icon-white");
jQuery(window).scroll(function() {
var scroll = jQuery(window).scrollTop();

if (scroll >= 115) {
jQuery("#sticky-icon").attr("src", "https://dummyimage.com/100x100/000/fff");

} else {
jQuery("#sticky-icon").attr("src", "https://via.placeholder.com/100/");
sticky.removeClass('not-sticky-icon-white').addClass('sticky-icon-white');
}

if (scroll >= 300) {
sticky.removeClass('sticky-icon-white').addClass('not-sticky-icon-white');
} else {
sticky.removeClass('not-sticky-icon-white').addClass('sticky-icon-white');
}
});
});


This is my HTML:



<div class="sticky-icon-white">
<img id="sticky-icon" src="https://via.placeholder.com/100/">
</div>


The replacing is working fine but I want to apply a slide or push (not sure what to call it) animation on it. Like this one: https://gosimple.com (the leaf icon in the middle).



But I couldn't figure out how. Could someone help me to find a solution, please?



Here is a JSFiddle: http://jsfiddle.net/bzqad296/



Thanks in advance!



I have tried with slideUp(); or slideDown(); but it doesn't work.



EDIT:



In this image, you can see the effect. How the icon changes from white background, green leafs to green background, white leafs:
https://prnt.sc/lgwr3f










share|improve this question
























  • Can you tell more about the effects you want? In which of that site are you referring to?
    – SilentCoder
    Nov 11 at 1:37










  • @SilentCoder, check out the edit in my question please. Thanks.
    – TPA
    Nov 11 at 8:30













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am replacing the src of an image when the user has scrolled to a certain point of the page with this jQuery code:



jQuery(function() {
var sticky = jQuery(".sticky-icon-white");
jQuery(window).scroll(function() {
var scroll = jQuery(window).scrollTop();

if (scroll >= 115) {
jQuery("#sticky-icon").attr("src", "https://dummyimage.com/100x100/000/fff");

} else {
jQuery("#sticky-icon").attr("src", "https://via.placeholder.com/100/");
sticky.removeClass('not-sticky-icon-white').addClass('sticky-icon-white');
}

if (scroll >= 300) {
sticky.removeClass('sticky-icon-white').addClass('not-sticky-icon-white');
} else {
sticky.removeClass('not-sticky-icon-white').addClass('sticky-icon-white');
}
});
});


This is my HTML:



<div class="sticky-icon-white">
<img id="sticky-icon" src="https://via.placeholder.com/100/">
</div>


The replacing is working fine but I want to apply a slide or push (not sure what to call it) animation on it. Like this one: https://gosimple.com (the leaf icon in the middle).



But I couldn't figure out how. Could someone help me to find a solution, please?



Here is a JSFiddle: http://jsfiddle.net/bzqad296/



Thanks in advance!



I have tried with slideUp(); or slideDown(); but it doesn't work.



EDIT:



In this image, you can see the effect. How the icon changes from white background, green leafs to green background, white leafs:
https://prnt.sc/lgwr3f










share|improve this question















I am replacing the src of an image when the user has scrolled to a certain point of the page with this jQuery code:



jQuery(function() {
var sticky = jQuery(".sticky-icon-white");
jQuery(window).scroll(function() {
var scroll = jQuery(window).scrollTop();

if (scroll >= 115) {
jQuery("#sticky-icon").attr("src", "https://dummyimage.com/100x100/000/fff");

} else {
jQuery("#sticky-icon").attr("src", "https://via.placeholder.com/100/");
sticky.removeClass('not-sticky-icon-white').addClass('sticky-icon-white');
}

if (scroll >= 300) {
sticky.removeClass('sticky-icon-white').addClass('not-sticky-icon-white');
} else {
sticky.removeClass('not-sticky-icon-white').addClass('sticky-icon-white');
}
});
});


This is my HTML:



<div class="sticky-icon-white">
<img id="sticky-icon" src="https://via.placeholder.com/100/">
</div>


The replacing is working fine but I want to apply a slide or push (not sure what to call it) animation on it. Like this one: https://gosimple.com (the leaf icon in the middle).



But I couldn't figure out how. Could someone help me to find a solution, please?



Here is a JSFiddle: http://jsfiddle.net/bzqad296/



Thanks in advance!



I have tried with slideUp(); or slideDown(); but it doesn't work.



EDIT:



In this image, you can see the effect. How the icon changes from white background, green leafs to green background, white leafs:
https://prnt.sc/lgwr3f







javascript jquery animation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 7:13

























asked Nov 11 at 1:27









TPA

13




13












  • Can you tell more about the effects you want? In which of that site are you referring to?
    – SilentCoder
    Nov 11 at 1:37










  • @SilentCoder, check out the edit in my question please. Thanks.
    – TPA
    Nov 11 at 8:30


















  • Can you tell more about the effects you want? In which of that site are you referring to?
    – SilentCoder
    Nov 11 at 1:37










  • @SilentCoder, check out the edit in my question please. Thanks.
    – TPA
    Nov 11 at 8:30
















Can you tell more about the effects you want? In which of that site are you referring to?
– SilentCoder
Nov 11 at 1:37




Can you tell more about the effects you want? In which of that site are you referring to?
– SilentCoder
Nov 11 at 1:37












@SilentCoder, check out the edit in my question please. Thanks.
– TPA
Nov 11 at 8:30




@SilentCoder, check out the edit in my question please. Thanks.
– TPA
Nov 11 at 8:30

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245065%2fcreate-up-down-slide-or-push-effect-with-jquery%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245065%2fcreate-up-down-slide-or-push-effect-with-jquery%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

さくらももこ

13 indicted, 8 arrested in Calif. drug cartel investigation