问题
I need to resize the orbit div(the container in which orbit content resides)according to size of the current image. Currently it seems that it is taking the size of the largest image.
Is it possible to get something on the lines of a onload event for orbit slider in Foundation 4.
I could get a handle using the after-slide-change event and do the resizing for all images except the first image(of course it because the slide change is fired when the image changes from 1 to 2).
$("#image-gallery-modal").bind('orbit:after-slide-change.fndtn.orbit', function(event){
var height = event.target.children[event.data[0].slide_number].children[0].children[0].clientHeight;
var containerWidth = $("#imgGal").parent().width();
var childrenCount = $("#imgGal").children().length;
var bulletContainerWidth = 14*childrenCount;
var leftOffest = (containerWidth - bulletContainerWidth)/2;
$('.orbit-bullets').css('margin-left',leftOffest+'px');
$("#imgGal").parent().css('height',height+'px');
});
image-gallery-modal
is my div
which contains orbit container, bullets and close button.
I got this idea from orbit.js. There is a line of code
.on('orbit:after-slide-change.fndtn.orbit', function(e, orbit) {
var $slide_number = $container.find('.' + self.settings.slide_number_class);
if ($slide_number.length === 1) {
$slide_number.replaceWith(self._slide_number_html(orbit.slide_number, orbit.total_slides));
}
})
Is there some way I can trigger an event onload of the orbit or something on those lines.
来源:https://stackoverflow.com/questions/16720069/how-to-get-the-callback-of-onload-event-for-orbit-slider-of-foundation-zurb-fram