Two-page view with jQuery.fancyBox

我与影子孤独终老i 提交于 2019-12-12 03:29:31

问题


I'm using jquery and fancyBox (may be replaced if you suggest).

My goal is to create a popup gallery with next/prev buttons, but images must be shown grouped by two, just like paper book.

I can easily show fancyBox popup and it works fine.

$.fancybox( ['image.jpg', 'image.jpg'] );

But, where should i look to display pages by two? I believe I should write some plugin for fancyBox. Or maybe you can offer another way.


回答1:


While it is not possible to display two photos out of the box, keep in mind that fancyBox can display any html code! That means, you could "build" a book by some other script or by yourself and then simply call fancybox manually:

$('#start-photo-book').on('click', function() {
  var book = [];

  $.each( $("#photo-book").children(), function( key, value ) {
    book.push({
      content : $( value ).clone(), 
      type    : 'html'
    })
  });

  $.fancybox.open( book, {
    loop : false,
    smallBtn : false
  });

});

See this demo:

http://codepen.io/fancyapps/full/OWObor/



来源:https://stackoverflow.com/questions/41507080/two-page-view-with-jquery-fancybox

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