From 29f9b03d2530ed485ae342dbbde1d012a41059d3 Mon Sep 17 00:00:00 2001 From: Lee EC Date: Wed, 9 Oct 2019 18:28:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20postmessage=20?= =?UTF-8?q?=E7=9B=91=E5=90=AC=E6=88=AA=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/index.html | 4 ++-- dist/index_demo.html | 4 ++-- info.json | 6 +++--- src/js/utils/controller.js | 9 +++++++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dist/index.html b/dist/index.html index a7ca342..3787901 100644 --- a/dist/index.html +++ b/dist/index.html @@ -6,7 +6,7 @@ demo - +
@@ -14,5 +14,5 @@
- + \ No newline at end of file diff --git a/dist/index_demo.html b/dist/index_demo.html index 0425625..32a37b7 100644 --- a/dist/index_demo.html +++ b/dist/index_demo.html @@ -8,7 +8,7 @@ - +
@@ -18,5 +18,5 @@ - + \ No newline at end of file diff --git a/info.json b/info.json index 0a7dfd7..5e2aac4 100755 --- a/info.json +++ b/info.json @@ -5,9 +5,9 @@ "title": "sina_wave", "ambName": "波浪", "github": "https://github.com/o2team-ambient/sina_wave", - "demoSnippet": "\n
\n \n
\n ", - "controlUrl": "//storage.jd.com/ambient/control-sina_wave.js?t=1569398853000", - "configUrl": "//storage.jd.com/ambient/config-sina_wave.js?t=1569398853000", + "demoSnippet": "\n
\n \n
\n ", + "controlUrl": "//storage.jd.com/ambient/control-sina_wave.js?t=1570616873000", + "configUrl": "//storage.jd.com/ambient/config-sina_wave.js?t=1570616873000", "placeholderImg": "//storage.jd.com/ambient/sina_wave_placeholder.png?t=1554260508000", "gifImg": "//storage.jd.com/ambient/sina_wave_motion.gif?t=1553781489000", "spriteImg": "//storage.jd.com/ambient/sina_wave_sprite.png?t=1554260508000" diff --git a/src/js/utils/controller.js b/src/js/utils/controller.js index 33ddb0a..93807c6 100755 --- a/src/js/utils/controller.js +++ b/src/js/utils/controller.js @@ -18,6 +18,7 @@ const isAmbientPlat = getParameterByName('platform') === '1' // 是否平台环 class Controller { ts + msgTs constructor () { this.config = window[O2_AMBIENT_CONFIG] || {} @@ -45,8 +46,12 @@ class Controller { bindMsg () { window.addEventListener('message', (msg) => { if (msg.data.type !== 'reset') return - window[O2_AMBIENT_CONFIG] = Object.assign(window[O2_AMBIENT_CONFIG], msg.data.data) - this.resetCanvas() + if (this.msgTs) return + this.msgTs = setTimeout(() => { + this.msgTs = null + window[O2_AMBIENT_CONFIG] = Object.assign(window[O2_AMBIENT_CONFIG], msg.data.data) + this.resetCanvas() + }, 200) }) }