Whenever we scroll elements, some HTML elements will be hidden. This tutorial gives a way to find out whether element is part of visible page or not.
Program Flow
- Find visible page Top and Bottom
- Find Element Top and Bottom
- The element is visible if its Top less than document view top and its Bottom greater than document view bottom
$scope.isScrolledIntoView = function(id) { var myEl = angular.element( document.querySelector( '#'+id ) ); // Find Page Top and Bottom var docViewTop = document.body.scrollTop; var docViewBottom = docViewTop + $window.innerHeight; // Find Element Top And Bottom var elemTop = myEl[0].offsetTop; var elemBottom = elemTop + myEl[0].offsetHeight; //If the element is part of visible page var visible = ((elemBottom <= docViewBottom) && (elemTop >= docViewTop)); alert(visible); }
The authors of the resource write my essay have extensive experience in writing coursework to order in any subject. If you order the work in advance, you can get a good result inexpensively
ReplyDelete