Search code examples
javascriptjquerygalleriaimage-rotation

Rotate an image with javascript in gallerio.io after load


I am using galleria 1.2.8. and i try to rotate an image after it is loaded by galleria. For this i am using the jquery rotate plugin (http://code.google.com/p/jqueryrotate/). I did attach to the "loadfinish" event and then do e.imageTarget.rotate(90). Then i get the error: "TypeError: e.imageTarget.rotate is not a function". When i do a "e.imageTarget" in the console i do get the img object, but i suspect that its not added to the DOM already and thats why its not working. I also tried to attach to the "image" event, but there i get the same error.

Any Ideas how i could make the rotation work with galleria?

Thanks, Sven


Solution

  • e.imageTarget is not a jQuery object, it's an HTML element, according to the docs:

    imageTarget (HTML element) The IMG element of the now loaded image before transition.

    HTML elements have no property called rotate. You need to wrap it in a jQuery object:

    this.bind("loadfinish", function(e) {
        $(e.imageTarget).rotate();
    });