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

Hello, I’ve seen the cm.on and cm.off 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.
cm.off(type: string, func: (...args))
Remove an event handler on the editor instance. An equivalent CodeMirror.off(object, type, func) also exists.

However I’ve tried several ways to disable scrolling and nothing seems to work:

cm.off('scroll', function() { return false;});
cm.off('scroll', function(event) { event.preventDefault(); return false: });
handler = function() { return false; };
cm.off('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?

Thanks

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