How to use .on and .off to manipulate scroll event

Hello, I’ve seen the cm.on and methods to enable or disable events as per the docs:

cm.on(type: string, func: (...args))
Register an event handler for the given event type (a string) on the editor instance. There is also a CodeMirror.on(object, type, func) version that allows registering of events on any object. string, func: (...args))
Remove an event handler on the editor instance. An equivalent, type, func) also exists.

However I’ve tried several ways to disable scrolling and nothing seems to work:'scroll', function() { return false;});'scroll', function(event) { event.preventDefault(); return false: });
handler = function() { return false; };'scroll', handler);

None of these disabled scrolling. Is it possible to see some examples on how to achieve this or how to properly use these .on and .off methods?


Scroll events can not be cancelled.

1 Like

Sorry to insist with this @marijn. Then… is there a way to implement drag scrolling in CodeMirror? Many thanks