react-native-canvas: AddEventListener will not trigger in Android
splitImage (canvas, x, y, rows, cols) {
const {height, width} = Dimensions.get('screen')
const CanvasXSize = width / cols - 2
const CanvasYSize = (height / 2) / rows
canvas.width = CanvasXSize
console.log('CanvasXSize',CanvasXSize);
canvas.height = CanvasYSize
const ctx = canvas.getContext('2d')
const img = new CanvasImage(canvas)
img.src = "https://scontent-sin6-2.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/21820297_280457069027480_5332287299113713664_n.jpg"
img.addEventListener('load', () => {
this.setState({ test: 'load' })
const imgW = img.width
console.log('imgW', imgW)
const imgH = img.height
const chunkWidth = imgW / cols
console.log('chunkWidth', chunkWidth)
const chunkHeight = imgH / rows
ctx.drawImage(
img,
x * chunkWidth,
y * chunkHeight,
chunkWidth,
chunkHeight,
0,
0,
CanvasXSize,
CanvasYSize
)
}, false)
}
I’m trying to split image based on the row and col and i manage to get everything working in ios but on android it can’t seem to trigger load event, did anyone know why and how to solve it?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 23 (12 by maintainers)
We’re having some issues on Android in the current version. Will dig into it when I’ll have a chance as this might affect my projects as well.
yes, sure , fighting with one 😃))