question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AddEventListener will not trigger in Android

See original GitHub issue
  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?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:23 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
iddancommented, Sep 25, 2017

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.

1reaction
Mactub07commented, Dec 12, 2017

yes, sure , fighting with one 😃))

Read more comments on GitHub >

github_iconTop Results From Across the Web

addeventlistener does not work when browsing on Android?
I Googled this and came across this: AddEventListener works on the browser but does not on Android, however there is no accepted answer....
Read more >
EventTarget.addEventListener() - Web APIs
Events that are bubbling upward through the tree will not trigger a listener designated to use capture. Event bubbling and capturing are two...
Read more >
Input events overview - Android Developers
Even if an input method presents a keyboard-like interface, it will generally not trigger the onKeyDown() family of events.
Read more >
Handling Events :: Eloquent JavaScript
Events and DOM nodes. Each browser event handler is registered in a context. In the previous example we called addEventListener on the window...
Read more >
HTMLFormElement: submit event - Web APIs | MDN
The event is not sent to the form when calling the form.submit() method ... a form that does not pass validation triggers an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found