Comments (5)
@sjwilliams I've just run into something that this would have helped on, particularly with a set of source elements in the video object. Trying to work on a solution, if I get it working I'll submit a PR.
from laziestloader.
That said, I think my problem is more on the support for the html5 video object. If I'm missing something let me know but looking at the source, getSource just looks for a src attr in the element we're passing through, which doesn't necessarily work for html5 video sets. Will 🔍
from laziestloader.
@erikreyna, yea it wouldn't work out of the box for <source>
nodes in the video
element.
Instead of getSource()
, could you do something like this?: (untested, just thinking out loud)
$('video').laziestloader({
threshold: 100,
setSourceMode: false // this is the important bit, and allows you to use laziest loader just to maintain scroll awareness
}, function(){
var slug = "SLUG"; // from a data attribute on the element or something..
var $video = $(this);
var srcWidth = $().laziestloader.bestFit($video.width(), [200, 700, 900, 1200]); // these are your available encode widths
var mp4 = '//somepath/toyour/media/'+slug+'-'+srcWidth+'.mp4';
var webm = '//somepath/toyour/media/'+slug+'-'+srcWidth+'.webm';
$video.append('<source src="'+mp4+'" type="video/mp4">');
$video.append('<source src="'+webm+'" type="video/webm">');
});
from laziestloader.
That looks like it could work, for now I'm headed another route to get this feature out the door but I'll probably still work on something that could work out of the box and submit a PR.
from laziestloader.
It's been a year and I've not felt the need to do this again. I tend to do something like the video example above when needed. I'm closing and can revisit later if need arises.
from laziestloader.
Related Issues (16)
- sort widths HOT 1
- {{size}} variable doesn't work in mustache templates HOT 1
- Prevent loading of smaller images on resize
- Expose the bestFit method HOT 1
- throttle scroll event HOT 1
- Sorten data-height-multiplier to simply data-ratio HOT 1
- Occasinally not loading assets on load HOT 2
- class to show loaded state HOT 7
- Inline element sizing issues HOT 2
- flag for "in view" instead of simply on scroll HOT 5
- fadeIn() images on lazyLoad HOT 4
- Slug-based widths are not sorted correctly HOT 1
- Laziestloader sans jQuery HOT 8
- iPhone X uses @3x assets
- JQMIGRATE deprecation
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 laziestloader.