From 9cce2c3381b062b2666d56982c2a8642d17d3546 Mon Sep 17 00:00:00 2001 From: MoyuScript Date: Fri, 11 Aug 2017 23:21:28 +0800 Subject: [PATCH] Fix pseudoelement image content not being loaded in time --- src/NodeContainer.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NodeContainer.js b/src/NodeContainer.js index 07a48d5..b13f57c 100644 --- a/src/NodeContainer.js +++ b/src/NodeContainer.js @@ -135,6 +135,17 @@ export default class NodeContainer { node.style.transform = 'matrix(1,0,0,1,0,0)'; } + // TODO move bound retrieval for all nodes to a later stage? + if (node.tagName === 'IMG') { + node.addEventListener('load', () => { + this.bounds = parseBounds(node); + this.curvedBounds = parseBoundCurves( + this.bounds, + this.style.border, + this.style.borderRadius + ); + }); + } this.image = getImage(node, imageLoader); this.bounds = IS_INPUT ? reformatInputBounds(parseBounds(node)) : parseBounds(node); this.curvedBounds = parseBoundCurves(