Is there a way to 'track' a moving element across a page, or continually scroll towards it, so that it never leaves the users view?
I've got an element which slowly moves across the page and eventually off screen, meaning the user has to scroll towards it to see it. This element continuously moves.
I'm using the ScrollTo Jquery plugin to guide the user towards this element, this works fine.
But, is there anyway to make it so the element is continually scrolled towards? So that it is tracked across the page?
At the moment the user has to repeatedly click a button to ScrollTo the element since it quickly moves out of view.
Any help is much appreciated.
You could try using a css hook if you're using a recent (> 1.4.3) version of jQuery. It depends on the property you are using to scroll it, let's say top
.
$.cssHooks["top"] = {
get: function(elem, computed, extra) {
return $.css(elem, 'top');
},
set: function(elem, value) {
// set it
$.css(elem, 'top');
$(document).scrollTo(value);
}
};
This means each time top
is set, it would call the set
function here.
If your query is just to keep the element in view of user : irrespective of his scrolling. Then why not just use simple " position: fixed" element.
Check out this link: http://www.w3.org/Style/Examples/007/menus.en.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.