Comments (4)
Hello @Daijobou !
Thanks for your improvments. I like your idea of a default_media
configuration parameter. I think i will adapt this. I will even take a look to you visibility function and validate changes within thr plugin.
But i don't understand your first point. That is exactly how Lazy works. It loads everything within a new image and after load set it to backgrounds or original elements. So what is the point of your example?
from jquery.lazy.
Thanks for your fast reply. ;)
@FIRST point
Ah thats fine! I was not sure :) Lazy Load XT have not this improvment https://github.com/ressio/lazy-load-xt/blob/master/src/jquery.lazyloadxt.bg.js ;)
@last point
I have add isElementVisible() function in XT and call it here: https://github.com/ressio/lazy-load-xt/blob/master/src/jquery.lazyloadxt.js#L209 So its only load visible elements on screen and not elements hidden in a overflow div. Working fine here. ;)
from jquery.lazy.
Thank you for explaining. ;)
As mentioned before, I will implement point 2 and take a look on point 3. I had to change it a bit in "my way", but i think it is a good idea.
Thanks!
from jquery.lazy.
Hello @Daijobou
I've added your feature request of a base path to the plugin, use version 0.6.3
. You will find an example an documentation of the new config parameter imageBase
on the project page: http://jquery.eisbehr.de/lazy/example_base-path
I've also looked on your isElementVisible
function. And yes, it workes corretly. But there are two porblems why I could not add it to Lazy.
- First because some (older) browser will not work correctly with
document.elementFromPoint
. - And second, the bigger problem, it's hella slow! In a test with about 1500 Images on a page its ended up totally lagging!
So yes, your aproach is correct, it will work, but it is not useable. I think its's okay to load images in the rare condition of overflow: hidden
but let the plugin works fast. Even if the images are not visible, they are lazy loaded.
If you really need this in your project, I append the function blow. Just replace them in your project. I'm sorry I'll yould not add it ...
/**
* check if the given element is inside the current viewport or threshold
* @access private
* @param {object} element
* @return {boolean}
*/
function _isInLoadableArea(element) {
var elementBound = element.getBoundingClientRect(),
direction = configuration("scrollDirection"),
threshold = configuration("threshold"),
visibleOnPoint = function(x, y) {
return element.contains(document.elementFromPoint(x, y));
},
vertical = // check if element is in loadable area from top
((_getActualHeight() + threshold) > elementBound.top) &&
// check if element is even in loadable are from bottom
(-threshold < elementBound.bottom),
horizontal = // check if element is in loadable area from left
((_getActualWidth() + threshold) > elementBound.left) &&
// check if element is even in loadable area from right
(-threshold < elementBound.right);
// if element is visible by viewport + threshold make a deeper visibility check
// like for elements in overflow hidden areas
if( (direction == "vertical" && vertical) || (direction == "horizontal" && horizontal) || (vertical && horizontal) )
return visibleOnPoint(elementBound.left, elementBound.top) ||
visibleOnPoint(elementBound.right, elementBound.top) ||
visibleOnPoint(elementBound.right, elementBound.bottom) ||
visibleOnPoint(elementBound.left, elementBound.bottom);
return false;
}
from jquery.lazy.
Related Issues (20)
- In Computer works like a charm. not working on mobile devices HOT 1
- Images downloading twice in Chrome HOT 2
- How to use jQuery.Lazy() Plugin with an image containing a cache-busting hash HOT 8
- Issue when using jQuery.Lazy() Plugin with a function AJAX call HOT 5
- images aren't shown if they doesn't come to visibility by scroll HOT 2
- images with srcset load all at once HOT 2
- Slow image load handling HOT 1
- Custom Content Loaders broken with jQuery 3.x HOT 4
- Doesn't trigger when new elements are toggled in HOT 2
- JS Error When Using on Cloned Template HOT 3
- laravel-mix, cannot reuse lazy HOT 1
- Deprecated
- Defer the lazy loading HOT 1
- Don`t change src when exists HOT 4
- Intermittent image load with AJAX return
- Custom loader using Ajax fails (not even fired), while lazyloading images work. HOT 1
- Bugs with gsap scrolltrigger in Safari HOT 3
- Throttling by number of calls HOT 1
- Images loading twice HOT 2
- Not able to get it working in FireFox 121.0.1 on Mac OS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery.lazy.