This is a library for the frond-end developer to add function: when the window scroll down to the position where users can't see the specific element, the specific element will locate to the specified location (And developer can set the position, sure!)
Actually, I have to thanks to this article, which guide me to finish this function and motivate me to package it as a library.
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/5.0.1/Rx.js"></script>
<script src="js/autoPosition.js"></script>
// params:
// box: the id name of element which you want to locate
// anchor : the id name of parenet element of the element you want to locate
autoPosition("box","anchor")
//element structure
<div id="anchor">
<div class="test" id="box">
</div>
</div>
// Provide four params now, to set the position after user scroll down
var attribute ={
top: "20px",
left: "100px",
width: "200px",
height: "200px"
}
autoPosition("box","anchor",attribute)