MCPcopy
hub / github.com/microsoft/monaco-editor / createToolbar

Function createToolbar

test/manual/index.js:113–186  ·  view source on GitHub ↗
(editor)

Source from the content-addressed store, hash-verified

111 }
112
113 function createToolbar(editor) {
114 var bar = document.getElementById('bar');
115
116 bar.appendChild(examplesComboBox.domNode);
117
118 bar.appendChild(modesComboBox.domNode);
119
120 bar.appendChild(themesComboBox.domNode);
121
122 bar.appendChild(
123 createButton('Dispose all', function (e) {
124 editor.dispose();
125 editor = null;
126 if (model) {
127 model.dispose();
128 model = null;
129 }
130 })
131 );
132
133 bar.appendChild(
134 createButton('Remove Model', function (e) {
135 editor.setModel(null);
136 })
137 );
138
139 bar.appendChild(
140 createButton('Dispose Model', function (e) {
141 if (model) {
142 model.dispose();
143 model = null;
144 }
145 })
146 );
147
148 bar.appendChild(
149 createButton(
150 'Ballistic scroll',
151 (function () {
152 var friction = 1000; // px per second
153 var speed = 0; // px per second
154 var isRunning = false;
155 var lastTime;
156 var r = 0;
157
158 var scroll = function () {
159 var currentTime = new Date().getTime();
160 var ellapsedTimeS = (currentTime - lastTime) / 1000;
161 lastTime = currentTime;
162
163 speed = speed - friction * ellapsedTimeS;
164 r = r + speed * ellapsedTimeS;
165 editor.setScrollTop(r);
166
167 if (speed >= 0) {
168 requestAnimationFrame(scroll);
169 } else {
170 isRunning = false;

Callers 1

index.jsFile · 0.85

Calls 2

createButtonFunction · 0.85
disposeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…