From 8a664b21458c4935fcc6fa6d4e27a03e8daaf2d8 Mon Sep 17 00:00:00 2001 From: wuzhigang Date: Fri, 24 Apr 2020 16:35:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Edestroy=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E9=A1=B5=E9=9D=A2=E9=94=80=E6=AF=81=E6=97=B6=E8=B0=83?= =?UTF-8?q?=E7=94=A8destroy=E5=8F=AF=E9=81=BF=E5=85=8D=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E4=BA=8C=E6=AC=A1=E6=B8=B2=E6=9F=93=E6=97=B6=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index 85b2e93..5dd5d50 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,9 @@ -import {setup, g} from './adapter' -const {window, document, navigator} = g +import { setup, g } from './adapter' +const { window, document, navigator } = g -;'__LOTTIE_CANVAS__' + ; '__LOTTIE_CANVAS__' -function loadAnimation(options) { +function loadAnimation (options) { ['wrapper', 'container'].forEach(key => { if (key in options) { throw new Error(`Not support '${key}' parameter in miniprogram version of lottie.`) @@ -20,11 +20,25 @@ function loadAnimation(options) { return window.lottie.loadAnimation(options) } -const {freeze, unfreeze} = window.lottie +const miniprogramDestroy = window.lottie.destroy + +const { freeze, unfreeze, getRegisteredAnimations } = window.lottie + +function destroy (name) { + const animations = getRegisteredAnimations() || [] + animations.forEach(animation => { + animation.wrapper = { + innerHTML: '' + } + }) + miniprogramDestroy(name) +} + export { setup, loadAnimation, freeze, unfreeze, + destroy }