Comments (2)
Hi there,
I'm guessing you got this from the Columbia Club site? This method of image loading has nothing to do with MixItUp, so please know it's not necessary for the plugin to work. It is however a nice way to integrate lazy image loading with MixItUp.
This way, we only load images when MixItUp filters in elements, and not on page load. Since we have hundreds of images on the page, we don't want to load them all at once and slow down the page load.
You're missing the part of the code that handles the data-src/src transfer:
$('#YourGridID').mixitup({
onMixLoad: function(config){
lazyLoad(config);
},
onMixEnd: function(config){
lazyLoad(config);
}
});
It's a function called lazyLoad() that I'm calling using the above callbacks, and it looks like this:
function lazyLoad(config){
$('#YourGridID').find('.'+config.filter).each(function(){
var $t = $(this),
src = $t.find('img').attr('data-src');
if(typeof $t.find('img').attr('src') !== 'undefined'){
$t.find('img').attr('src',src);
};
});
};
After the data-src url is transfered to the src attribute, the image then loads as normal, and fires the onload function when it's done. This fades in the image by adding the .loaded class to the img_wrapper. You should be aware that if you are loading 'all' elements on load, or multiple filters, this code won't work, I just knocked it up for that specific project and it should not be considered a one size fits all solution.
Hope this helps. If you're not building something with lots and lots of images on the page though, there's no need to use this method.
from mixitup.
Ok thanks for the clear explanation. I was actually just trying to get a basic image grid to work but after much experimentation, I am making a little headway but it's tricky for responsive as you have to think in multi-dimensional terms. I've tried Masonry, Isotope and Packery but did not have much luck with those in terms of using images. I think your script will get me where I need to be I hope. Looking at your client portfolio is awe inspiring. Thanks.
from mixitup.
Related Issues (20)
- Human Readable list combined with reset buttons
- Using Mixitup with multiple custom styled select dropdowns
- Provide examples on how to use mixitup inside Next.js
- Sorting and Filtering causes duplicate content
- Update mixer pagination limit on window resize with mixer.configure() HOT 1
- Mix runs 4 times on page load.
- Pagination scrolling issue with CSS property `scroll-behavior` set on `:root`
- Combining multi filter and pagination with url filtering unsecsessful
- how to filter by attribute, not by class? HOT 1
- Reset button + toggle problems with WEBFLOW integration
- Switching from one filter to second one with less items makes some items overshoot their position HOT 3
- .
- Website & Documentation 404'ing.
- mixer became busy after first filtration HOT 2
- Accessible pagination
- Reset the tabindex on pagination change
- MixItUp Pagination not working with Vite JS
- Invalid certificate on official library website HOT 2
- Uncaught TypeError: t.className.match is not a function
- mixitup related issue
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 mixitup.