Determines whether the page element enters the viewable area

Source: Internet
Author: User
Recently to do a page function, you need to detect whether a page element is located in the current screen of the visual area, the first thought of course is to obtain offsetleft and offsettop, this value is compared with Body.scrolltop/scrollleft, respectively, To see if the element is visible. This time to check the information by chance to see Getboundingclientrect (); The method obtains the left, top, right, and bottom of an element in the page, respectively, relative to the position of the browser window, and he returns an object, object, which has a property: Top,left,right, Bottom: Here the top, left and CSS are very similar to the understanding, but Right,bottom and CSS in the understanding is a little different, see: 1125232802013230062896/

Determines whether the page element enters the viewable area

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.