English 中文(简体)
How can I create a photo slider on iPhone Safari with jQuery?
原标题:

I d like to create an product image viewer for an iPhone version of an ecommerce site, and have it behave something like the Photos app.

Ideally, you would be able to slide images to move back and forth in the product image gallery.

This will all be done in mobile Safari.

I did a little experimenting with jqTouch, but its doesn t look like it would support this idea (it has swipe support, but there s no apparent way to link sliding to dragging an image).

Any plugin or implementation ideas? Thanks!

问题回答

i needed the same, solution was to use cycle and swipe plugins:

"#gallery" is a container with all img tags in it.

$(function() {
 $( #gallery ).cycle({
  fx:  scrollHorz ,
  timeout: 0,
  next:   ,
  prev:   ,
  speed: 300,
  nowrap: 0
 });
});
$(function() {
 $( #gallery ).swipe({
  swipeLeft: function() { $( #gallery ).cycle("next"); },
  swipeRight: function() { $( #gallery ).cycle("prev") },
  threshold: {
   x: 15,
   y: 99999
  },
  preventDefaultEvents: false
 });
});

it works, but not exactly like Photo library, because images doesnt drag to 50% of width before changing. just like in crmunro s solution, but based on jQuery and plugins.

not sure if you ve solved this, but an iWebkit a user has created http://worldofsai.com/photos_flick.html - maybe you could base it on that?

you can check this example. open it in safari on your iPhone))) you can rotate, move and scale images

Qtouch received a significant update in july. The full source package now include demos for video embedding and swipeable image galleries.

You can find the download of r148 at this url: http://code.google.com/p/jqextensions/downloads/list

It works very well.





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签