Giter VIP home page Giter VIP logo

Comments (4)

artpolikarpov avatar artpolikarpov commented on May 27, 2024

To get access to the attached images, use this snippet:

$('.fotorama').on('fotorama:load', function (e, fotorama, data) {
  var $img = $('.fotorama__img', data.frame.$stageFrame);
});

from fotorama.

ssp avatar ssp commented on May 27, 2024

Thanks for that hint Artem.

That certainly helps when the image is loaded the first time, but the load event does not fire when I’m scrolling around the images and an image is redisplayed later on because it is already loaded then.

I thought the show event should do the trick but I find it hard to figure out the correct new image there (probably because it takes a moment for the animation to finish.

from fotorama.

artpolikarpov avatar artpolikarpov commented on May 27, 2024

Do you really need to get the image twice and more? I was thinking that it is enough to touch it once.

If so, try to combine the fotorama:showend event and the private f:load:

function catchImage ($frame) {
  var $img = $('.fotorama__img', $frame);
  // do something smart with $img
}

$('.fotorama')
    .on('fotorama:showend', function (e, fotorama) {
      var $frame = fotorama.activeFrame.$stageFrame;

      if (!$frame.data('state')) {
        $frame.on('f:load', function () {
          catchImage($frame);
        });
      } else {
        catchImage($frame);
      }
    })
    .fotorama();

Also you have to add data-auto="false" attribute to the fotorama block, to skip automatic initialization.

from fotorama.

ssp avatar ssp commented on May 27, 2024

Do you really need to get the image twice and more? I was thinking that it is enough to touch it once.

I do: there is only one image zoomer which is just transferred to the current image. So I need to know when that happens.

If so, try to combine the fotorama:showend event and the private f:load:

Indeed that does the trick!

Thanks again

from fotorama.

Related Issues (20)

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.