在safari&铬而不是ff&歌剧

时间:2013-02-25 15:10:34

标签: javascript jquery css jquery-ui cross-browser

我正在使用名为jb gallery 3.0的图像滑块 - 使用jQuery运行。

它只是一个普通的图像滑块,但它有一个功能,可以检测浏览器大小,然后将图像缩放到浏览器的大小,即。如果你在iPad上观看它会给你一个较小的图像,这样你仍然可以看到整个画面。

每次在滑块中加载图像时都会进行调整大小,因此如果您在幻灯片之间调整窗口大小,下次加载图像时它将被缩放...无需刷新页面。

这一切都很好用于safari和chrome,但在firefox和opera(12.14)它没有,它只是提供裁剪的全尺寸图像......

我已经对这里发生的事情做了一个小问题 - http://jsfiddle.net/ktvvW/5/ - 尝试在chrome或safari中调整“结果”面板的大小,看看发生了什么。

知道为什么这在ff或opera中不起作用?

.

干杯

4 个答案:

答案 0 :(得分:3)

强制jbgallery-3.0.js脚本上的webkit行为似乎解决了这个问题。 请参阅下面的选项,我强制webkit为true(忽略userAgent)。 我已经在FF和Opera上测试了它,功能与预期一致,图像显示与Chrome中相同的缩放。

$(".jbgallery").jbgallery({  
    style    : "zoom",       //"centered"|"zoom"|"original" - image style  
    menu     : "simple",         //false|"numbers"|"simple"|"slider" - menu type  
    shortcuts: [37, 39],         //[prev,next] - keyboard code shortcuts  
    slideshow: true,            //true|false - autostart slideshow  
    fade     : true,             //true|false - disable all fade effects  
    popup    : false,            //true|false - modal box & traditional popup hack to display multiple gallery (3.0 : fullscreen:false)  
    randomize: 0,                //0|1|2 - randomize first image (1) or randomize "slideshow" (2) - blackout: http://www.grayhats.org  
    caption  : false,             //true|false - show/disable internal caption system  
    autohide : false,            //true|false - auto hide menu & caption  
    clickable: false,            //true|false - "image click & go"  
    current  : 1,                //number     - set initial photo (modal "hack" - see demo. don't use "hash". jbgallery use "location.hash" only in popup mode)  
//    webkit   : (navigator.userAgent.toLowerCase().search(/webkit/) != -1),  //boolean - used for specific browser hack. if you want, you can force disable this flag & try to find crossbrowser solution  
    webkit   : true,
    ie6      : (/MSIE 6/i.test(navigator.userAgent)), //boolean - IDEM  
    ie7      : (/MSIE 7/i.test(navigator.userAgent)), //boolean - IDEM  
    labels   : {                 //labels of internal menu  
        play : "play",  
        next : "next",  
        prev : "prev",  
        stop : "stop",  
        close: "close",  
        info : "info"  
    },  
    timers   : {                 //timers   
        fade    : 1000,           //fade duration  
        interval: 3000,          //slideshow interval  
        autohide: 7000           //autohide timeout  
    },  
    delays: {                    //delays (timers) to improve usability and reduce events  
        mousemove: 200,          //used by autohide. cancel autohide timeout every XXXms.   
        resize   : 10,          //used by ie6 to reduce events handled by window.resize  
        mouseover: 800           //used by tooltip. show tooltip only if the mouse STAY over thumb for XXXms  
    },  
    close    : function(){},     //callback handled by menu's button close. see demo. example : close : function(){window.close()}  
    before   : function(){},     //callback handled BEFORE image gallery loaded  
    after    : function(ev){},   //callback(ev) handled AFTER image gallery loaded. receive the native load event.  
    load     : function(ev){},   //callback(ev) handled AFTER native image load event. receive the native load event.  
    ready    : function(el){$('.jbg-menu').hide(); $('.jbg-loading').remove(); $('.jbg-caption').remove(); $('.jbg-menu-opacity').remove();},   //callback(el) handled AFTER jbgallery render. receive the HTML element.  
    fullscreen: false,            //true|false : the most important feature of jbgallery 3.0. now jbgallery can "stay in a box" and have multiple istance in one page.  
    push      : function(o){},   //callback handled by push public method (JBGALLERY API). receive the object/string/array of objects/array of strings passed from external. useful for external menu system  
    unshift   : function(o){},   //callback handled by unshift public method (JBGALLERY API). receive the object/string/array of objects/array of strings passed from external.  
    shift     : function(){},    //callback handled by shift public method   
    pop       : function(){},    //callback handled by pop public method   
    empty     : function(){}     //callback handled by empty public method   
});

这是link to my jsfiddle

答案 1 :(得分:0)

似乎是一个问题的CSS。

<强>原始

.jbgallery .jbgallery-target.zoom {
    min-height: 50%;
    min-width: 50%;
}

<强>修饰

.jbgallery .jbgallery-target.zoom {
    height: 50%;
    width: 50%;
}

错误必须在css面板中添加css,因为原始文件位于插件css中

这是新css的链接 http://jsfiddle.net/ktvvW/8/

答案 2 :(得分:0)

我想我知道该怎么做:

更改负载功能如下:

load     : function(ev){$(".zoom").css("width",$("#slider").width()),$(".zoom").css("height","auto");$(".zoom").css("left","0px");$(".zoom").css("top","auto")},

它适用于所有浏览器,经过测试并成功运作

答案 3 :(得分:0)

我对此没有完整的答案,但我过去也遇到过类似的问题。我了解到Gecko(Firefox)和Webkit(Safari和Chrome)不能以相同的方式处理图像。当我尝试缩放图像时,图像大小的信息不可用,因此无法使用相同的代码缩放它们。

我只能建议对image + onload事件进行一些研究。在我看来,这将是一个javascript问题。