Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 221858 Details for
Bug 391048
[iOs6] No requests will be sent anymore after executing window.setInterval() while scrolling
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
ios6 bug workaround
ios6_timer.patch (text/plain), 5.47 KB, created by
Claudio Guglielmo
on 2012-10-03 13:04:28 EDT
(
hide
)
Description:
ios6 bug workaround
Filename:
MIME Type:
Creator:
Claudio Guglielmo
Created:
2012-10-03 13:04:28 EDT
Size:
5.47 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.rap.rwt/js/qx/client/IOS6TimerPatch.js b/bundles/org.eclipse.rap.rwt/js/qx/client/IOS6TimerPatch.js >new file mode 100644 >index 0000000..2ff9f36 >--- /dev/null >+++ b/bundles/org.eclipse.rap.rwt/js/qx/client/IOS6TimerPatch.js >@@ -0,0 +1,144 @@ >+(function (window) { >+ >+ // This library re-implements setTimeout, setInterval, clearTimeout, clearInterval for iOS6. >+ // iOS6 suffers from a bug that kills timers that are created while a page is scrolling. >+ // This library fixes that problem by recreating timers after scrolling finishes (with interval correction). >+ // This code is free to use by anyone (MIT, blabla). >+ // Author: rkorving@wizcorp.jp >+ >+ var Client = org.eclipse.rwt.Client; >+ var applyPatch = false; >+ if(Client.getPlatform() === "ios") { >+ if(navigator.appVersion.indexOf("OS 6") > 0) { >+ applyPatch = true; >+ } >+ } >+ >+ if(!applyPatch) { >+ return; >+ } >+ >+ var timeouts = {}; >+ var intervals = {}; >+ var orgSetTimeout = window.setTimeout; >+ var orgSetInterval = window.setInterval; >+ var orgClearTimeout = window.clearTimeout; >+ var orgClearInterval = window.clearInterval; >+ >+ >+ function createTimer(set, map, args) { >+ var id, cb = args[0], repeat = (set === orgSetInterval); >+ >+ function callback() { >+ if (cb) { >+ cb.apply(window, arguments); >+ >+ if (!repeat) { >+ delete map[id]; >+ cb = null; >+ } >+ } >+ } >+ >+ args[0] = callback; >+ >+ id = set.apply(window, args); >+ >+ map[id] = { args: args, created: Date.now(), cb: cb, id: id }; >+ >+ return id; >+ } >+ >+ >+ function resetTimer(set, clear, map, virtualId, correctInterval) { >+ var timer = map[virtualId]; >+ >+ if (!timer) { >+ return; >+ } >+ >+ var repeat = (set === orgSetInterval); >+ >+ // cleanup >+ >+ clear(timer.id); >+ >+ // reduce the interval (arg 1 in the args array) >+ >+ if (!repeat) { >+ var interval = timer.args[1]; >+ >+ var reduction = Date.now() - timer.created; >+ if (reduction < 0) { >+ reduction = 0; >+ } >+ >+ interval -= reduction; >+ if (interval < 0) { >+ interval = 0; >+ } >+ >+ timer.args[1] = interval; >+ } >+ >+ // recreate >+ >+ function callback() { >+ if (timer.cb) { >+ timer.cb.apply(window, arguments); >+ if (!repeat) { >+ delete map[virtualId]; >+ timer.cb = null; >+ } >+ } >+ } >+ >+ timer.args[0] = callback; >+ timer.created = Date.now(); >+ timer.id = set.apply(window, timer.args); >+ } >+ >+ >+ window.setTimeout = function () { >+ return createTimer(orgSetTimeout, timeouts, arguments); >+ }; >+ >+ >+ window.setInterval = function () { >+ return createTimer(orgSetInterval, intervals, arguments); >+ }; >+ >+ window.clearTimeout = function (id) { >+ var timer = timeouts[id]; >+ >+ if (timer) { >+ delete timeouts[id]; >+ orgClearTimeout(timer.id); >+ } >+ }; >+ >+ window.clearInterval = function (id) { >+ var timer = intervals[id]; >+ >+ if (timer) { >+ delete intervals[id]; >+ orgClearInterval(timer.id); >+ } >+ }; >+ >+ window.addEventListener('scroll', function () { >+ // recreate the timers using adjusted intervals >+ // we cannot know how long the scroll-freeze lasted, so we cannot take that into account >+ >+ var virtualId; >+ >+ for (virtualId in timeouts) { >+ resetTimer(orgSetTimeout, orgClearTimeout, timeouts, virtualId); >+ } >+ >+ for (virtualId in intervals) { >+ resetTimer(orgSetInterval, orgClearInterval, intervals, virtualId); >+ } >+ }); >+ >+}(window)); >\ No newline at end of file >diff --git a/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/displaykit/ClientResources.java b/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/displaykit/ClientResources.java >index 0edb656..55810df 100644 >--- a/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/displaykit/ClientResources.java >+++ b/bundles/org.eclipse.rap.rwt/widgetkits/org/eclipse/swt/internal/widgets/displaykit/ClientResources.java >@@ -57,6 +57,7 @@ > "qx/event/type/DataEvent.js", > "qx/event/type/ChangeEvent.js", > "qx/client/Timer.js", >+ "qx/client/IOS6TimerPatch.js", > "qx/html/String.js", > "qx/dom/String.js", > "qx/html/Entity.js",
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 391048
: 221858