Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
499 views
in Technique[技术] by (71.8m points)

php - best approach for jQuery slider with dynamic prev/next content?

layout

Here's a somewhat complex puzzle, I'd love some feedback on how others would approach this.

This site is basically a free regional news blog. The image at the bottom demonstrates the layout (ignore the date overlap glitch). It's coded in PHP, jQuery and xajax.

My question has to do with dynamic content loading. As is, on page-load, I assign the arrows to the URL of the prev/next articles. No prob. The URLs are friendly, the page reloads to the next article, and I can cycle through them all day long.

But ... I'd like to turn the arrows into a slider (not an href) with the following behavior:

Clicking the right arrow will ...

  1. Begin loading the new content offscreen via xajax,
  2. Cause the old content to slide left (from onscreen to offscreen) flush with the new content also sliding left (from offscreen to onscreen).

Why? Sliders are awesome, and I think it would look pro. And this is basic slider stuff (like this jQuery scrollLeft slider) except with content being dynamically loaded on click of the arrow, which raises some questions:

  • What's the best approach for this?
  • Do I use PHP to pre-populate ALL empty hidden article DIVs?
  • Do I use jQuery to append/prepend/remove article DIVs with each arrow click?
  • What would the jQuery "scrollLeft" offset look like? The content DIV is static width, but would I be better off with jQuery scrollTo?

I hope my question is clear ... Any suggestions would be most appreciated!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here's the solution I came up with.

http://jsfiddle.net/tXUwZ/

If anyone has ideas on how to clean it up or make it tighter, please let me know!

Many thanks to @Jamie for the push in the right direction!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...