Giter Site home page Giter Site logo

Comments (5)

erikreyna avatar erikreyna commented on July 19, 2024

@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.

erikreyna avatar erikreyna commented on July 19, 2024

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.

sjwilliams avatar sjwilliams commented on July 19, 2024

@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.

erikreyna avatar erikreyna commented on July 19, 2024

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.

sjwilliams avatar sjwilliams commented on July 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.