-
12 Jul 2012 11:04 AM #1
Finding out if an element is hidden by scrolling
Finding out if an element is hidden by scrolling
Is there a way to determine that an element is below or above the display of a scrolled container, in other words out of sight?
-
12 Jul 2012 11:14 PM #2
Hi!
i have a container with scrolling in it.
now i am finding is my element (under container) is hide or not (Due to scrolling)
for more info, refer to this:-Code:function elementStateInScrolling(yourElem){ var containerTop = yourContainer.getScroll( ).top() , containerBottom = containerTop + yourContainer.getHeight() , elemTop = yourElem.getEl().getY() , elemBottom = elemTop + yourElem.getHeight(); return ((elemBottom <= containerBottom) && (elemTop >= containerTop)); }
http://stackoverflow.com/questions/4...fter-scrollingsword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
17 Jul 2012 3:49 PM #3
Thanks for the help! I had to make a slight adjustment to your code to get it to work in my situation:
I'm passing in the container object and using getY to get it's top position instead of top.Code:elementStateInScrolling: function (el,ctr){ var containerTop, containerBottom, elemTop, elemBottom; containerTop = ctr.getY(); containerBottom = containerTop + ctr.getHeight(); elemTop = el.getY(); elemBottom = elemTop + el.getHeight(); return ((elemBottom <= containerBottom) && (elemTop >= containerTop)); }


Reply With Quote