简体   繁体   中英

JavaScript smooth scroll - iphone

Are there any plugins or does anyone know of a good way to achieve the iPhone elastic band scroll? working example in flash http://www.shinedraw.com/text-effect/silverlight-3-and-flash-iphone-dragging-effect/

I'm looking to drag and scroll a div, but if it goes past a certain point it bounces back.

Thanks

查看iScroll

Once you have figured out how to scroll it, it's very simple in mootools to obtain that "bounce" effect.

For example, you can apply a particular bounce effect in this way:

//element is supposed to be the main div you want to drag on iPhone
var element = $('elementID');

//instantiate a morph fx referred to that element
var bounceEffect = new Fx.Morph(element,{duration:1000, transition:Fx.Transitions.Bounce.easeOut});

//...then, when you want it to bounce back (e.g. at the release, or when it goes below a certain position) you can do:

bounceEffect.start({'top':0});

Edit: take a look @ mootouch too, it's a very interesting project

德鲁麦科马克写了一篇文章为MacResearch有关的弹跳和滚动势头的物理位置 ,其中包括复制多少你在iPhone上看到的行为的JavaScript代码。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM