🐛 Gcode Viewer: Prevent middle mouse wheel from scrolling the entire page and panning the canvas (#4274)
Fixes #4218
This commit is contained in:
1 parent
a1dee07d76
commit
14c2d49d12
1 file changed
+13
@@ -371,6 +371,7 @@ $(function () {
|
||||
|
||||
self._configureLayerSlider(layerSliderElement);
|
||||
self._configureLayerCommandSlider(commandSliderElement);
|
||||
self._configureContainerElement(containerElement);
|
||||
|
||||
self.settings.firstRequest.done(function () {
|
||||
var initResult = GCODE.ui.init({
|
||||
@@ -475,6 +476,18 @@ $(function () {
|
||||
.on("slide", self.changeCommandRange);
|
||||
};
|
||||
|
||||
self._configureContainerElement = function (containerElement) {
|
||||
// Prevent the default browser action for the mouse wheel down event. The desired behavor is to have the
|
||||
// gocde canvas pan on mouse down + drag, which happens. But if we don't prevent the default action, the browser
|
||||
// will also scroll the entire page.
|
||||
containerElement.mousedown(function (event) {
|
||||
// Middle mouse button
|
||||
if (event.which === 2) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.loadFile = function (path, date) {
|
||||
self.enableReload(false);
|
||||
self.needsLoad = false;
|
||||
|
||||
Reference in new issue
Block a user