开发者

Detect the specific element and scroll to vertically down

开发者 https://www.devze.com 2023-03-03 15:31 出处:网络
I have an item page and each item has an \"image link\", hovering mouse over image link a t开发者_JAVA百科ool tip is shown describing the item. My page is scrollable that indicates good amount of item

I have an item page and each item has an "image link", hovering mouse over image link a t开发者_JAVA百科ool tip is shown describing the item. My page is scrollable that indicates good amount of items are viewed. My problem is when I am at the bottom of the page, and put mouse over the "image Link" the tool-tip is not fully shown [half is covered by the window]. So What I want is as soon as I am on the image link and if I see the tool-tip will not be fully shown, I will scroll down the page by the amount of width pixel of the tool-tip. I tried this, but this happens for all image link, but I need for the last image-link in the page visibile area. [I need javascript help]

   var totalHeight, currentScroll, visibleHeight
    currentScroll = GetScrollTop();
    totalHeight = document.body.offsetHeight;
    visibleHeight = document.documentElement.clientHeight;


    if (e.pageY <= currentScroll + visibleHeight) {  //This is always true         
        window.scrollTo(0, currentScroll + 100);

    }

Thanks in advance.


Here is an edge-aware tooltip

http://plugins.learningjquery.com/cluetip/demo/


screenH = window.screen.height; //THIS WILL VISBLE SCREEN HEIGHT
a = window.scrollY; //this will give current y- scroll  positon 
if(a > screenH){
 window.scrollTo(0, a + 100);
} 

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号