moagrius / isonscreen Goto Github PK
View Code? Open in Web Editor NEWSimple jQuery plugin to determine if an element is within the viewport
License: MIT License
Simple jQuery plugin to determine if an element is within the viewport
License: MIT License
Hi,
good work, this plugin!
Question:
What if the element is larger (e.g. higher) than the viewport?
In this case we have the element even more than 100% on screen.
How can that be checked and made to result in "true" with this plugin?
Thank you :)
So I'm using a theme that I believe is using an older version of your code and I'm getting the following error
TypeError: undefined is not an object (evaluating 'bounds.left')
I did a console.log(bounds) and bounds has valid values for left and top. Testing in Chrome and Safari.
$.fn.is_on_screen = function(){
var win = $(window);
var viewport = {
top : win.scrollTop(),
left : win.scrollLeft()
};
viewport.right = viewport.left + win.width();
viewport.bottom = viewport.top + win.height();
var bounds = this.offset();
bounds.right = bounds.left + this.outerWidth();
bounds.bottom = bounds.top + this.outerHeight();
return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
};
Hi,
Your script has come in really handy. Thanks.
I need to know what license you distribute the code under to be able to include it in my project but I can't find it.
Do you use a license for this code? It'd be great to have a free one.
Thanks again.
Chris.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.