Pergunta

Sei que posso usar as opções de largura de quadro e peso de estrutura para controlar o tamanho do quadro para conteúdo embutido e iframe, mas o que posso fazer para controlar manualmente o tamanho do quadro ao exibir imagens?

Meu problema é que tenho imagens que quero exibir em um FancyBox extremamente horizontal e não muito verticalmente; A FancosBox escala -o, para que a caixa de luz seja realmente larga e não muito alta, o que significa que você não pode realmente ver a imagem.

O que eu gostaria é ter a imagem rolando horizontalmente na caixa de luz. (E não, não posso mudar as imagens).

Alguma ideia?

Site Fancosbox

Foi útil?

Solução

Acabei apenas invadindo o FancyBox e adicionando outra opção para fazer o que eu queria. Aqui está a essência:

if (opts.imgManSize) { 
   _set_content('<img alt="" id="fancy_img" src="'+imagePreloader.src+'" />',opts.imgWidth,imagePreloader.height+20);
} else {
   _set_content('<img alt="" id="fancy_img" src="'+imagePreloader.src+'" />',width,height);
}

...

if (opts.imgManSize) { 
  $("#fancy_content").css('overflow','auto');
}

...

if (opts.imgManSize) { 
  $('#fancy_img').css('width','auto');
}

...

$.fn.fancybox.defaults = {
   ...
   imgManSize:false,
   imgWidth:425,
   imgHeight:355,
   ...
}

Funciona como um encanto.

Outras dicas

You can just make the frame size adjust in relation to the size of the image, by modifying the CSS.

To overwrite width and height declarations the plugin creates, add:

#fancybox-inner {
    width: auto!important;
    height: auto!important;
}

#fancybox-wrap{
    width: auto!important;
    height: auto!important;
}

and remove position:absolute on #fancybox-inner

I had this issue myself, and wrote some code to solve this for embedding the new Vimeo IFRAME'd videos based on an existing snippet I found. This will allow you to add URL parameters for WIDTH and HEIGHT on a fancybox by fancybox basis. If you don't add them the default will open an IFRAME with a height of 90% and 90%.

(function($){ 
    $(function(){
        // Fancybox: IFRAME
        var fancybox_iframe = $('.fancybox-iframe');
        if (fancybox_iframe.length > 0){
            fancybox_iframe.each(function(index){
                // Inline frame width param
                if( $(this).attr('href').match(/width=[0-9]+/i) ){
                    var fWidth = parseInt($(this).attr('href').match(/width=[0-9]+/i)[0].replace('width=',''));
                } else {
                    var fWidth = '90%';
                }
                // Inline frame height param
                if( $(this).attr('href').match(/height=[0-9]+/i) ){
                    var fHeight = parseInt($(this).attr('href').match(/height=[0-9]+/i)[0].replace('height=',''));
                } else {
                    var fHeight = '90%';
                }
                if(window.console&&window.console.log) { 
                    console.log('fWidth #'+index+': '+fWidth); 
                    console.log('fHeight #'+index+': '+fHeight); 
                }
                $(this).fancybox({
                    'titlePosition' : 'inside',
                    'type'              : 'iframe',
                    'autoScale'         : true,
                    'padding'           : '10',
                    'width'             : fWidth,
                    'height'                : fHeight,
                    'centerOnScroll'    : true
                });
            });
        }
    });
})(jQuery);

To use this you would use the following:

<a href="http://player.vimeo.com/video/16429685?color=ffffff&width=800&height=450" class="fancybox-iframe" title="Citizen Schools 101">Inline Vimeo Video</a>

I hope this helps someone out!

Wrap the image in a div (if its inline) or in a page if you are using the ajax load. Then, set the style on the div to the width of your iframs and set the overflow css attribute to overflow:scroll;

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top