Ace: How to bind scroll event ?

Created on 29 Oct 2015  ·  7Comments  ·  Source: ajaxorg/ace

How to bind scroll event to the editor ?

editor.on('scroll', function() {
    //...
}) ?

or

editor.getSession().on('scroll', function() {
    //...
}) ?

Most helpful comment

editor.session.on("changeScrollTop", function() {})
editor.session.on("changeScrollLeft", function() {})

All 7 comments

editor.session.on("changeScrollTop", function() {})
editor.session.on("changeScrollLeft", function() {})

thx!

@nightwing is there a way to get current, first _and_ last line number?

editor.session.on("changeScrollTop", function() {})
editor.session.on("changeScrollLeft", function() {})

Once event is binded then how to unbind it again. I have tried

editor.session.off();
editor.session.off('scroll');
editor.session.off('changeScrollTop');
var listener = function() {}
session.on("eventName", listener)
session.off("eventName", listener)
var listener = function() {}
session.on("eventName", listener)
session.off("eventName", listener)

Actually I have tried using an empty function but it doesn't work.

session.off('changeScrollTop', function() {
});
session.off('changeScrollLeft', function() {
});

you need to pass the same function to on and off methods

Was this page helpful?
0 / 5 - 0 ratings