问题
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