Skip to content

Instantly share code, notes, and snippets.

@zmmbreeze
Created December 19, 2013 08:15
Show Gist options
  • Save zmmbreeze/8035994 to your computer and use it in GitHub Desktop.
Save zmmbreeze/8035994 to your computer and use it in GitHub Desktop.
Is element in client view. use tangram
var inView = function (e) {
var clientW = baidu.page.getViewWith();
var clientH = baidu.page.getViewHeight();
var rect = e.getBoundingClientRect();
return (rect.bottom > 0 && rect.top < clientH)
&& (rect.right > 0 && rect.left < clientW);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment