Repository: incubator-weex-site Updated Branches: refs/heads/master 5168b983c -> 6ab444d5b
* [doc] add application foreground or background event for globalEvent Project: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/commit/bf47606a Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/tree/bf47606a Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/diff/bf47606a Branch: refs/heads/master Commit: bf47606a927dd70d9fcf539b8d2b1cffdecde484 Parents: 85e6720 Author: acton393 <zhangxing610...@gmail.com> Authored: Mon Jan 22 19:47:57 2018 +0800 Committer: acton393 <zhangxing610...@gmail.com> Committed: Mon Jan 22 19:47:57 2018 +0800 ---------------------------------------------------------------------- source/cn/references/modules/globalevent.md | 21 +++++++++++++++++++++ source/references/modules/globalevent.md | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex-site/blob/bf47606a/source/cn/references/modules/globalevent.md ---------------------------------------------------------------------- diff --git a/source/cn/references/modules/globalevent.md b/source/cn/references/modules/globalevent.md index 38c3689..c83c764 100644 --- a/source/cn/references/modules/globalevent.md +++ b/source/cn/references/modules/globalevent.md @@ -87,3 +87,24 @@ globalEvent.addEventListener("geolocation", function (e) { var globalEvent = weex.requireModule('globalEvent'); globalEvent.removeEventListener("geolocation"); ``` + +## å·²æçå ¨å±äºä»¶ +<span class="weex-version">0.14</span> +### åºç¨ååäºä»¶ +WeexSDK 对è·ååºç¨ååå°äºä»¶åäºæ¯æï¼å¼åè å¯ä»¥å¨é¡µé¢å çå¬å¯¹åºçäºä»¶ï¼è·å¾åºç¨è¢«åååè¿åå°ï¼ä»¥æ¹ä¾¿æåé³ä¹ï¼è§é¢çï¼åªéè¦æå®éè¦çå¬çäºä»¶å称ååè°å½æ°å°±å¯ä»¥ï¼ä¾å¦ï¼ + +``` +var globalEvent = weex.requireModule('globalEvent'); +globalEvent.addEventListener("WXApplicationDidBecomeActiveEvent", function (e) { + console.log("WXApplicationDidBecomeActiveEvent"); +}); +``` +æ¯æçäºä»¶å称 + + - WXApplicationDidBecomeActiveEvent åºç¨è¢«åå°çæ¶å触å + - WXApplicationWillResignActiveEvent åºç¨å³å°è¢«åå°æ¶å触å + +å¨ [dotWe ä¸è¯ä¸è¯](http://dotwe.org/vue/5a774e8ce3766c88038cab6fe3331f5b) + +>>> ç®ååªæ platform 为 iOS å Android æè½æ¯æã[è·åå½å platform](../weex-variable.html#weex-environment-object) + http://git-wip-us.apache.org/repos/asf/incubator-weex-site/blob/bf47606a/source/references/modules/globalevent.md ---------------------------------------------------------------------- diff --git a/source/references/modules/globalevent.md b/source/references/modules/globalevent.md index 9612d60..0253e65 100644 --- a/source/references/modules/globalevent.md +++ b/source/references/modules/globalevent.md @@ -88,3 +88,22 @@ var globalEvent = weex.requireModule('globalEvent'); globalEvent.removeEventListener("geolocation"); ``` +## Built-in global event +<span class="weex-version">0.14</span> +### background or foreground event +You can specify the event name as `WXApplicationDidBecomeActiveEvent ` or `WXApplicationWillResignActiveEvent` to obtain application becoming foreground or background, so that you can pause your video or music at this time.For example + +``` +var globalEvent = weex.requireModule('globalEvent'); +globalEvent.addEventListener("WXApplicationDidBecomeActiveEvent", function (e) { + console.log("WXApplicationDidBecomeActiveEvent"); +}); +``` + +- `WXApplicationDidBecomeActiveEvent` fired while application did become foreground +- `WXApplicationWillResignActiveEvent` fired while application will become background + +[have a try at DotWe](http://dotwe.org/vue/5a774e8ce3766c88038cab6fe3331f5b) + +>>> this feature only works on iOS and Android platforms, it doesn't work on Web. [Obtain your weex platform on weex page](../weex-variable.html#weex-environment-object) +