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.

Stopping interaction will throw errors

See original GitHub issue

First, thank you for an amazing library!

I have a situation where I need to stop interaction in the onstart-event due to a competing gesture that has to lock down all other touch events in the app.

Even though it has the desired effect, calling interaction.stop() in the Draggable’s onstart-event throws errors, which are currently filling the error logs of my app.

...
    onstart: function(event) {
    	event.interaction.stop();
    },
...

Reproduction: https://jsfiddle.net/a8j9bta5/

Is this the appropriate way to stop the interaction? I couldn’t find anything else in the API for the task.

Expected behavior

Nothing should happen.

Actual behavior

Dragging doesn’t start (as it should), but erros get thrown. Seems that depending on browsers or other external variables the error thrown is a bit different.

Uncaught TypeError: Cannot read property 'options' of null
    at Ma (interact.min.js:9)
    at xa.setModifications (interact.min.js:52)
    at xa.pointerMove (interact.min.js:61)
    at HTMLDocument.<anonymous> (interact.min.js:16)

System configuration

interact.js version: v1.2.8 Browser name and version: Chrome 56.0.2924.87, Safari 10.0, basically all browsers Operating System: Os X 10.11.6, Android 5, iOS 10 …

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tayecommented, Apr 14, 2017

@nikparo from v1.3.0-alpha.0 onwards, actions are started by default only with the left mouse button (54ebdc3).

@arggh sorry, I overlooked where the error was actually happening. I’m working on it now.

0reactions
nikparocommented, May 21, 2019

Can’t remember where I got it from or whether it’s documented or not, but I’m calling interact.stop() from a dragstart handler and it has been working just fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Stopping function after exception - Stack Overflow
If I have more code that needs to be run after the try catch statement, I'd like it only to be can if...
Read more >
Clean Code and the Art of Exception Handling - Toptal
There is nothing wrong with the previous code. But overusing these patterns will cause code smells, and won't necessarily be beneficial. Likewise, misusing...
Read more >
A mostly complete guide to error handling in JavaScript.
Learn how to deal with errors and exceptions in synchronous and asynchronous JavaScript code.
Read more >
Exceptions and debugging - Advanced R. - Hadley Wickham
Fatal errors are raised by stop() and force all execution to terminate. Errors are used when there is no way for a function...
Read more >
Exceptions in coroutines. Cancellation and Exceptions in…
Imagine a UI-related CoroutineScope that processes user interactions. If a child coroutine throws an exception, the UI scope will be cancelled and the...
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