javascript - Element visible betwen scroll points -


i have element visible when scroll bigger 890px. have problem element has visible between 890px , 920px, , if user scroll more thna 920 or less 890px need hide element.

i using animated css adding animation element when appear.

this have in js

var $document = $(document),     $elementfield = $('.center-field');  $document.scroll(function () {     if ($document.scrolltop() >= 890) {         $elementfield.stop().addclass("show animated bounceindown");       } }); 

now appear when user scroll more 890px, when user goes stay again, there somekind of watch user scroll?

just bit more specific if condition.

var $document = $(document),      $elementfield = $('.center-field');    $document.scroll(function () {    if ($document.scrolltop() >= 890 && $document.scrolltop() <= 920) {      $elementfield.css('color', 'tomato');      } else {      $elementfield.css('color', 'blue');     }  });
body {    position: relative;    height:1800px;  }    .center-field {    position: absolute;    top: 900px;    color: blue;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>  <p>scroll down please</p>  <h1 class="center-field">hello</h1>


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -