I have a mailchimp subscribe newsletter form. I want the form to scroll down alongwith the page is scroll.
Right now it just fadeIn
, fadeOut
when the page is scrolled but I want it to also move down when the user is scrolling the page down.
this is my html.
<div class="container">
<div class="row">
<div class="pull-right">
<!-- Begin MailChimp Signup Form -->
<link href="//cdn-images.mailchimp.com/embedcode/slim-10_7.css" rel="stylesheet" type="text/css">
<form id="subscribe-form" name="mc-embedded-subscribe-form" class="validate">
<p>Sign up for our newsletter</p>
<div id="signup_scroll">
<div class="mc-field-group">
<label for="mce-EMAIL">Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" required>
</div>
<div class="clear"><input type="submit" value="Submit" name="subscribe" id="subscribe" class="button"></div>
</div>
</form>
</div>
</div>
</div>
JS
var amountScrolled = 300;
$(window).scroll(function() {
if ( $(window).scrollTop() > amountScrolled ) {
$('#subscribe-form').fadeIn('slow');
} else {
$('#subscribe-form').fadeOut('slow');
}
});
$('#subscribe-form').click(function() {
$('html, body').animate({
scrollTop: 0
}, 700);
return false;
});