Building A Custom Scroll-bar for the Ace Editor.

1,562 views
Skip to first unread message

Abdulaziz Alaboudi

unread,
Feb 26, 2016, 3:43:50 AM2/26/16
to Ajax.org Cloud9 Editor (Ace)
  I am trying to have the Ace editor scrolls whenever I scroll another div. On other words, I want to have one scroll-bar for a custom div as well as the Ace editor.

Any suggestion, please!

Aziz     

Harutyun Amirjanyan

unread,
Feb 27, 2016, 2:08:04 PM2/27/16
to ace-d...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Ajax.org Cloud9 Editor (Ace)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ace-discuss...@googlegroups.com.
To post to this group, send email to ace-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/ace-discuss.
For more options, visit https://groups.google.com/d/optout.

Abdulaziz Alaboudi

unread,
Feb 27, 2016, 7:54:01 PM2/27/16
to Ajax.org Cloud9 Editor (Ace)
Thank you Harutyun very much for your response! Could you please elaborate more on how I would use this code to implement a custom scroll-bar?

Thank you again!


Aziz

Harutyun Amirjanyan

unread,
Feb 28, 2016, 7:53:17 AM2/28/16
to ace-d...@googlegroups.com
this depends on details of what exactly you want to do.
Where is the custom div, what is in it. How do you make div and editor to have the same size.

Abdulaziz Alaboudi

unread,
Feb 28, 2016, 1:35:36 PM2/28/16
to Ajax.org Cloud9 Editor (Ace)

 
Thank you Harutyun for your response!

The custom div is actually a gutter on the right side of the Ace editor. Inside the gutter, there are divs that represent lines in the Ace editor. Therefore, each time the user press enter and adds a new line to the Ace editor, the gutter dynamically adds a div to match that new line.

Now, I want to have one scroll-bar both for the gutter and the Ace editor.

At this moment, I have the following code


<div   id="gutter" onscroll="scrolled()" >



function scrolled(){
   
      jsEditor.getSession().setScrollTop( someValue );
     
}


 
I have also attached pictures of how the current gutter and Ace editor look like. Please have a look at them.


I really appropriate your help! Thank you very much again  
2016-02-28_13-08-39.png
2016-02-28_13-15-55.png
2016-02-28_13-19-08.png

Harutyun Amirjanyan

unread,
Feb 29, 2016, 4:22:45 PM2/29/16
to ace-d...@googlegroups.com
you can either hide the editor.renderer.scrollbarV.element
and modify editor.renderer.scrollbarV.setScrollTop/setScrollHeight to work on your div
or change getWidth
editor.renderer.scrollBarV.getWidth = function() {return 200}; 
editor.resize(true)
and add divs to editor.renderer.scrollbarV.element instead


Reply all
Reply to author
Forward
0 new messages