iOS 开发实用技术导航
NSHipster 中文版
› http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
› http://www.cocos2d-iphone.org/
CocoaPods
› http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
› http://code.google.com/mobile/analytics/
WWDC
› https://developer.apple.com/wwdc/
Design Guides and Resources
› https://developer.apple.com/design/
Transcripts of WWDC sessions
› http://asciiwwdc.com
Cocoa with Love
› http://cocoawithlove.com/
Cocoa Dev Central
› http://cocoadevcentral.com/
NSHipster
› http://nshipster.com/
Style Guides
› Google Objective-C Style Guide
› NYTimes Objective-C Style Guide
Useful Tools and Services
› Charles Web Debugging Proxy
› Smore
shuding
V2EX  ›  iDev

( iOS 浏览器)难道真的没办法在滚动时运行 JS 吗?

  •  
  •   shuding ·
    shuding · Dec 25, 2014 · 7477 views
    This topic created in 4332 days ago, the information mentioned may be changed or developed.

    setTimeout、setInterval、onscroll、requestAnimationFrame 都试过了……
    均会在惯性滚动的时候被暂停 _(:з」∠)_
    真的没有好的解决办法么 0 0?

    以及,scrolling end 是不是也不能监听到?

    10 replies  •  2015-05-11 18:59:08 +08:00
    bumz
    bumz
    Dec 25, 2014❤️1
    1
    有一種辦法,那就是禁用掉 iOS 自帶的滾動,自己模仿一個。 https://bumfo.github.io/overflow.html 額外的好處是可以實現毛玻璃效果~ https://workspace.v2ex.com/file/c64143a0-8ba7-11e4-9d18-42010af0ecaa/2849178970-5463896a48365.jpeg
    bumz
    bumz
    Dec 25, 2014❤️1
    2
    等等,剛纔試了一下,你確信 scrolling 的時候是無法執行 js,不是無法更新 scroll layer dom?

    我這裏,requestAnimationFrame,js 一直好好地執行呢 (iOS 8 Safari),而且無論更新 scroll layer 還是 fixed layer 都無問題(iOS7 好像只能更新 fixed layer)。
    shuding
    shuding
    OP
    Dec 25, 2014
    3
    @bumz 谢谢!你的 demo 实在太棒了!

    我的测试是 iOS 7 > <,scrolling 确实会暂停。

    搜到一些资料,(iOS 7 里边)确实是 Apple 暂停掉了。
    看来是 iOS 8 有改变: http://developer.telerik.com/featured/scroll-event-change-ios-8-big-deal/
    yyfearth
    yyfearth
    Dec 25, 2014
    4
    说是js会执行 但是不paint
    hkongm
    hkongm
    Dec 25, 2014
    5
    IOS8的SAFARI才有了真正的scroll事件。
    alexrezit
    alexrezit
    Dec 25, 2014
    6
    @shuding
    iOS 8 更新的內容之一.
    shuding
    shuding
    OP
    Dec 25, 2014
    7
    @hkongm @alexrezit 谢谢(所以大概是因为我还在用 7,才没发现这一点吧……QAQ
    iyangyuan
    iyangyuan
    Dec 25, 2014
    8
    好像滚动的时候,css animation也会停掉。。。
    whatisnew
    whatisnew
    May 11, 2015
    9
    现在有好的解决方案了吗?快速滑动的时候,animation 就废了。。。
    @bumz
    bumz
    bumz
    May 11, 2015 via iPad
    10
    @whatisnew iOS 8 一切正常,iOS 7 除了自製滾動外,不可能有比較完美的解決方案。

    不過 fixed 和 sticky 的元素在滾動時可以被 js 更新,雖然 css 動畫被暫停,但是也可以用 js 操縱動畫。。。

    demo: https://bumfo.github.io/anim.html

    iOS 7 下,保持手指移動,動畫繼續
    然而如果手指沒有移動,目前也沒有什麼辦法能讓動畫繼續了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2790 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 14:19 · PVG 22:19 · LAX 06:19 · JFK 09:19
    ♥ Do have faith in what you're doing.