使用 z-index、php、xml 和 jquery/cycle.js 的密集幻灯片

发布于 2024-10-17 08:22:12 字数 762 浏览 5 评论 0原文

所以我正在做这个项目,创意总监给了我一个难题。

他使用 flash 创建了一个原型,该原型需要使用 jQuery、XML(或 PHP)来构建,以拉入所有内容和图像,然后在相同的 div 尺寸内切换也通过 XML 拉入的更多信息。

我被允许最大程度地使用 JS,这意味着如果我使用 JS 拉取图像,我会给它们一个特定的命名约定。无需进一步告别:

http://joeylabs.com/sites/sgc/prototype/

顺便说一句,由于某种原因,此页面将幻灯片一直推到底部,因此要查看整个内容,只需滚动到底部即可。 :)

所以我的想法是:

  1. 通过 php 目录扫描脚本或使用图像命名约定使用 jquery 从文件夹中提取图像。
  2. 然后使用 Cycle.js 我创建一个变量,用于在 onBefore 中保存 li before 内的图像,并创建一个变量,用于在 onAfter 中保存 li after 内的图像,将它们分别浮动在 z-index 小于 1 的 div 中比当前幻灯片。 (我还不知道如何做到这一点)
  3. 当前幻灯片有一个百叶窗过渡,当用户单击“下一步”时,它会触发 2 张幻灯片,一张在下面,一张在上面。

目前这都是理论,但您不认为可以运行 2 个循环幻灯片,一个在另一个之上,用 1 个触发器吗?有人对此有什么想法、建议吗?

So I'm working on this project and the creative director has thrown a curveball my way.

He's created with flash a prototype that needs to be built with jQuery, XML (or PHP) pulling in all the content and images, and then within the same div dimensions toggle more information that's also pulled in via XML.

I'm allowed to use JS to the fullest extent which means if I'm pulling images with JS I'll give them a specific naming convention. Without further adieu:

http://joeylabs.com/sites/sgc/prototype/

Btw, for some reason this page pushes the slideshow all the way to the bottom so to view the entire thing just scroll to the bottom. :)

So what I'm thinking is:

  1. Pull images from folder via php directory scan script or with jquery using an image naming convention.
  2. Then using Cycle.js I'd create a variable that holds the image inside the li before with onBefore and a variable that holds the image inside the li after with onAfter, float both of them respectively in a div with a z-index 1 less than the current slide. (I don't know how to do this yet)
  3. The current slide has a blinds transition and when the user clicks NEXT it is a trigger for 2 slideshows, one below and one on top .

This is all theory at this point but don't you think it would be possible to run 2 Cycle slideshows, one on top of the other with 1 trigger? Anyone have thoughts, tips, on this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

打小就很酷 2024-10-24 08:22:12

是的,我将每个 img 嵌套在两个 div 和两个 div 中以将其包裹起来...

<div id="before_window_wrapper">
  <div name="before_n_after_window">

    <div id="before_slide_wrapper">
       <div id="before_slide">
         <img src"my/image/directory/1.img"/>
       </div>
       <div id="slide_comment">
         <h3>person comment for this img goes here</h3>
       </div>
    </div>

    <div id="before_slide_wrapper">
      <div id="before_slide">
        <img src"my/image/directory/3.img"/>
      </div>
        <div id="slide_comment">
         <h3>person comment for this img goes here</h3>
       </div>
   </div>

  </div>
</div>

并且:

<div id="after_window_wrapper">
  <div name="before_n_after_window">

    <div id="after_slide_wrapper">
       <div id="after_slide">
         <img src"my/image/directory/2.img"/>
       </div>
       <div id="slide_comment">
         <h3>person comment for this img goes here</h3>
       </div>
    </div>

    <div id="after_slide_wrapper">
      <div id="after_slide">
        <img src"my/image/directory/4.img"/>
      </div>
       <div id="slide_comment">
         <h3>person comment for this img goes here</h3>
       </div>
    </div>

  </div>
</div>

“before_n_after_window”的子项是正在循环的 div:

$("#before_n_after_window").each(function(index){
  $(this).cycle();
});

幻灯片包装器(before_slide_wrapper 和 after_slide_wrapper)位于 Cycle() 下完全控制-很好。但是,嵌套在其中的任何内容都不是,因此您可以为幻灯片放置更多同级(before_slide 和 after_slide) - 因此是“#slide_comment”div。

“before_n_after_window”仅在cycle()的半控制下,并使用与其自身不冲突的CSS代码。 “#before_window_wrapper”和“#after_window_wrapper”由您完全控制(css-wise)。

现在您已经有了“#before_n_after_window”及其子项,只需迭代它们并命名并指向每对控件:

var i = index;
var current_slide = $(this);

// hides the pause button
$('#pause_button_'+i).hide();
//checks index for odd or even
i = (i%=2) ? ((index+1)/2) : ((index/2)+1);

$(current_slide).cycle({
  fx:    'fade',
  pager:    '#nav_' + i,
  prev:     '#previous_button_' + i,
  next:     '#next_button_' + i,
});

// I want to only show the play or pause button at any given time
$(current_slide).cycle('pause');
$('#play_button_'+i).click(function(){
  $(current_slide).cycle('resume', true); 
  $('#pause_button_'+i).show();
  $('#play_button_'+i).hide();
});
$('#pause_button_'+i).click(function() { 
  $(current_slide).cycle('pause'); 
  $('#pause_button_'+i).hide();
  $('#play_button_'+i).show();
});

您必须遵循上面的命名约定或您可能决定的任何其他命名约定。实际的控件可以放置在除窗口内部之外的任何地方 - 错误问题。

附带说明一下,我将这些对设置为在循环后立即暂停,因为我不想在页面上运行多张幻灯片。我希望用户选择循环哪一个。另外,我必须找到一种方法来关闭可能正在运行的任何其他周期。
然而:

if(better_solution){
  return please_post;
}

yes, I nested each of my img in two divs and two divs to wrap things up...

<div id="before_window_wrapper">
  <div name="before_n_after_window">

    <div id="before_slide_wrapper">
       <div id="before_slide">
         <img src"my/image/directory/1.img"/>
       </div>
       <div id="slide_comment">
         <h3>person comment for this img goes here</h3>
       </div>
    </div>

    <div id="before_slide_wrapper">
      <div id="before_slide">
        <img src"my/image/directory/3.img"/>
      </div>
        <div id="slide_comment">
         <h3>person comment for this img goes here</h3>
       </div>
   </div>

  </div>
</div>

and:

<div id="after_window_wrapper">
  <div name="before_n_after_window">

    <div id="after_slide_wrapper">
       <div id="after_slide">
         <img src"my/image/directory/2.img"/>
       </div>
       <div id="slide_comment">
         <h3>person comment for this img goes here</h3>
       </div>
    </div>

    <div id="after_slide_wrapper">
      <div id="after_slide">
        <img src"my/image/directory/4.img"/>
      </div>
       <div id="slide_comment">
         <h3>person comment for this img goes here</h3>
       </div>
    </div>

  </div>
</div>

the children of "before_n_after_window" are the divs that are being cycled:

$("#before_n_after_window").each(function(index){
  $(this).cycle();
});

The slide wrappers (before_slide_wrapper and after_slide_wrapper) are under cycle()'s complete control -fine. However, any thing nested inside of it is not, so you can place more siblings for the slides(before_slide and after_slide) - hence the "#slide_comment" div.

"before_n_after_window" is only under semi-control of cycle(), and uses your css code that doesn't conflict with its own. "#before_window_wrapper" and "#after_window_wrapper" are under your complete control(css-wise).

Now that you have"#before_n_after_window" and its children, simply iterate through them and name and point the controls for each pair:

var i = index;
var current_slide = $(this);

// hides the pause button
$('#pause_button_'+i).hide();
//checks index for odd or even
i = (i%=2) ? ((index+1)/2) : ((index/2)+1);

$(current_slide).cycle({
  fx:    'fade',
  pager:    '#nav_' + i,
  prev:     '#previous_button_' + i,
  next:     '#next_button_' + i,
});

// I want to only show the play or pause button at any given time
$(current_slide).cycle('pause');
$('#play_button_'+i).click(function(){
  $(current_slide).cycle('resume', true); 
  $('#pause_button_'+i).show();
  $('#play_button_'+i).hide();
});
$('#pause_button_'+i).click(function() { 
  $(current_slide).cycle('pause'); 
  $('#pause_button_'+i).hide();
  $('#play_button_'+i).show();
});

You must follow the naming convention above or any other you may decide on. the actual controls can be be place anywhere except inside the windows - bug issues.

On a side note, I set these pairs to pause immediately after they've been cycled because I didn't want several slide running on on page. I wanted the user to choose which one to cycle. Also, I have to find a way to turn off any other cycles that may be running.
However:

if(better_solution){
  return please_post;
}
〆一缕阳光ご 2024-10-24 08:22:12

我认为您不会进行任何目录抓取 - 您将从哪里获取有关每个图像的其余信息(标题、说明文字等)。您需要将每个部分放入数据库中,并参考图像,当用户单击“了解更多”按钮、部分名称、预览标题等时应打开哪个子部分。

我建议使用Galleria 插件:http://galleria.aino.se/

对于子页面(“了解更多”的目的地“按钮),您可以将其 AJAX 到您拉动的绝对 div 中以覆盖整个幻灯片放映。这使得关闭按钮很容易实现 - 它只是将绝对 div 全部删除。

I don't think you'll be doing any directory scraping - where are you going to get the rest of the information about each image from (title, caption, etc). You'll need to put each section in a database, with reference to the image, which subsection should be opened when the user clicks the "learn more" button, section name, preview caption, etc.

I would suggest using a variant of the Galleria plugin: http://galleria.aino.se/

For the subpages (the destination for the "learn more" button), you can AJAX that into an absolute div that you pull to cover the entire slide show. That makes the close button easy to implement - it just removes the absolute div all together.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文