You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ta...@apache.org on 2017/05/25 02:46:28 UTC
[46/50] incubator-weex git commit: * [html5] release v0.11.39 & load
img asynchronously.
* [html5] release v0.11.39 & load img asynchronously.
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/0268618b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/0268618b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/0268618b
Branch: refs/heads/0.13-dev
Commit: 0268618ba7ed8db01568429a7bc31026e993d12c
Parents: 3aaba51
Author: MrRaindrop <te...@gmail.com>
Authored: Wed May 24 13:21:55 2017 +0800
Committer: MrRaindrop <te...@gmail.com>
Committed: Wed May 24 13:21:55 2017 +0800
----------------------------------------------------------------------
html5/render/vue/mixins/base.js | 4 ++--
html5/render/vue/utils/lazyload.js | 11 +++++++++++
html5/render/vue/utils/perf.js | 11 +++++++++++
package.json | 2 +-
packages/weex-vue-render/package.json | 2 +-
5 files changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0268618b/html5/render/vue/mixins/base.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/mixins/base.js b/html5/render/vue/mixins/base.js
index 6c9c38b..9393685 100644
--- a/html5/render/vue/mixins/base.js
+++ b/html5/render/vue/mixins/base.js
@@ -75,11 +75,11 @@ export default {
mounted () {
if (this.$options._componentTag === 'image') {
- global._has_image_in_first_screen = true
+ window._has_image_in_first_screen = true
}
if (this === this.$root) {
tagRootMounted()
- if (!global._has_image_in_first_screen) {
+ if (!window._has_image_in_first_screen) {
tagFirstScreen()
}
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0268618b/html5/render/vue/utils/lazyload.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/utils/lazyload.js b/html5/render/vue/utils/lazyload.js
index c8bd369..0fab86d 100644
--- a/html5/render/vue/utils/lazyload.js
+++ b/html5/render/vue/utils/lazyload.js
@@ -50,6 +50,17 @@ export function applySrc (item: any, src: ?string, placeholderSrc: ?string): voi
}
}
}
+
+ /**
+ * 1. apply src immediately in case javscript blocks the image loading
+ * before next tick.
+ */
+ item.style.backgroundImage = `url(${src || ''})`
+
+ /**
+ * 2. then load the img src with Image constructor (but would not post
+ * a request again), just to trigger the load event.
+ */
if (item._src_loading) {
return
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0268618b/html5/render/vue/utils/perf.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/utils/perf.js b/html5/render/vue/utils/perf.js
index 9542a53..b7ccbcf 100644
--- a/html5/render/vue/utils/perf.js
+++ b/html5/render/vue/utils/perf.js
@@ -92,6 +92,7 @@ const perf: {
const tmp = {}
const IMG_REC_INDENT: number = 500 // record loading events after 500ms towards last recording.
+const REGEXP_IMG_TYPE = /(.png|.jpg|.webp|.gif)$/ // image file type regexp.
let earliestBeforeUpdateTime: number = 0
let earliestBeforeCreateTime: number = 0
@@ -153,6 +154,9 @@ function getEntries (): Array<any> {
const performance = window.performance
return performance && performance.getEntries
? performance.getEntries()
+ .filter(function (entry) {
+ return entry.initiatorType === 'img' || REGEXP_IMG_TYPE.test(entry.name)
+ })
: [{ responseEnd: getNow() - IMG_REC_INDENT }]
}
@@ -209,6 +213,13 @@ export function tagFirstScreen (time?: number): void {
const debouncedTagImg = debounce(function () {
const entries = getEntries()
const len = entries.length
+ if (!len) {
+ /**
+ * no image loaded. This probably happened because of the disabling of images' loading
+ * events. So just tag now as the first screen time.
+ */
+ return tagFirstScreen()
+ }
let i = 0
let end = 0
while (i < len) {
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0268618b/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index bc73a69..fb6e1e0 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
"subversion": {
"browser": "0.5.0",
"framework": "0.20.5",
- "vue-render": "0.11.38",
+ "vue-render": "0.11.39",
"transformer": ">=0.1.5 <0.5"
},
"description": "A framework for building Mobile cross-platform UI",
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0268618b/packages/weex-vue-render/package.json
----------------------------------------------------------------------
diff --git a/packages/weex-vue-render/package.json b/packages/weex-vue-render/package.json
index bb90cac..2a8e3e5 100644
--- a/packages/weex-vue-render/package.json
+++ b/packages/weex-vue-render/package.json
@@ -1,6 +1,6 @@
{
"name": "weex-vue-render",
- "version": "0.11.38",
+ "version": "0.11.39",
"description": "Weex built-in components for Vue 2.x.",
"license": "Apache-2.0",
"main": "dist/index.js",