Elegantly auto-resize Galleria jQuery slideshow when window is resized

痞子三分冷 提交于 2020-01-03 05:08:07

问题


I am using the Galleria jQuery slideshow plugin. I can get the slideshow to fill the full browser window by specifying the width and height with $(document).width() and $(document).height() and everything works as desired. Code below:

Galleria.loadTheme('galleria/themes/classic/galleria.classic.min.js');
$("#gallery").galleria({
    width: $(document).width(),
    height: $(document).height()
});

I also put in the following code to handle when the window is resized:

$(window).resize(function() {
    location.reload();
});

That works but it does a full screen refresh and isn't as elegant as Galleria's implementation, http://galleria.io/themes/fullscreen/. Is there a way to resize the slideshow without having to reload the entire page using the default skin?


回答1:


I don't have a way to test this. But something like this may be worth a shot.

var gal = $("#gallery").galleria({
    width: $(document).width(),
    height: $(document).height()
});  

$(window).resize(function() {
      gal.width = $(document).width();
      gal.height = $(document).height();
});



回答2:


Turns out if I use the extend functionality I can set the slideshow to be full screen and it will automatically resize when the window is resized without reloading the full page.

$("#gallery").galleria({
    width: $(document).width(),
    height: $(document).height(),
    extend: function() {
    this.enterFullscreen();
    }
});


来源:https://stackoverflow.com/questions/8846313/elegantly-auto-resize-galleria-jquery-slideshow-when-window-is-resized

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!