Skip to content

Commit

Permalink
#82 workarea related javascript convertion changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AgriyaDev5 committed Mar 12, 2021
1 parent 835a345 commit e572058
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
18 changes: 9 additions & 9 deletions src/editor/extensions/ext-overview_window/ext-overview_window.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ export default {

// Define dynamic animation of the view box.
const updateViewBox = function () {
const portHeight = Number.parseFloat($('#workarea').css('height'));
const portWidth = Number.parseFloat($('#workarea').css('width'));
const portX = $('#workarea').scrollLeft();
const portY = $('#workarea').scrollTop();
const warea = document.getElementById('workarea');
const portHeight = parseFloat(getComputedStyle(warea, null).height.replace("px", ""));
const portWidth = parseFloat(getComputedStyle(warea, null).width.replace("px", ""));
const portX = warea.scrollLeft;
const portY = warea.scrollTop;
const windowWidth = Number.parseFloat($('#svgcanvas').css('width'));
const windowHeight = Number.parseFloat($('#svgcanvas').css('height'));
const overviewWidth = $('#overviewMiniView').attr('width');
Expand All @@ -65,12 +66,12 @@ export default {
$('#overview_window_view_box').css('top', viewBoxY + 'px');
$('#overview_window_view_box').css('left', viewBoxX + 'px');
};
$('#workarea').scroll(function () {
document.getElementById('workarea').addEventListener('scroll', () => {
if (!(overviewWindowGlobals.viewBoxDragging)) {
updateViewBox();
}
});
$('#workarea').resize(updateViewBox);
document.getElementById('workarea').addEventListener('resize', updateViewBox);
updateViewBox();

// Compensate for changes in zoom and canvas size.
Expand Down Expand Up @@ -101,9 +102,8 @@ export default {

const portX = viewBoxX / overviewWidth * windowWidth;
const portY = viewBoxY / overviewHeight * windowHeight;

$('#workarea').scrollLeft(portX);
$('#workarea').scrollTop(portY);
document.getElementById('workarea').scrollLeft = portX;
document.getElementById('workarea').scrollTop = portY;
};
const onStart = function () {
overviewWindowGlobals.viewBoxDragging = true;
Expand Down
7 changes: 4 additions & 3 deletions src/editor/panels/LayersPanel.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-len */
/* eslint-disable no-alert */
/* globals $ */
import SvgCanvas from '../../svgcanvas/svgcanvas.js';
Expand Down Expand Up @@ -29,11 +30,11 @@ class LayersPanel {
* @returns {void}
*/
changeSidePanelWidth (delta) {
const rulerX = $('#ruler_x');
const rulerX = document.querySelector('#ruler_x');
$('#sidepanels').width('+=' + delta);
$('#layerpanel').width('+=' + delta);
rulerX.css('right', Number.parseInt(rulerX.css('right')) + delta);
this.editor.workarea.css('right', Number.parseInt(this.editor.workarea.css('right')) + delta);
rulerX.style.right = (parseFloat(getComputedStyle(rulerX, null).right.replace("px", "")) + delta) + "px";
this.editor.workarea.style.right = (parseFloat(getComputedStyle(this.editor.workarea, null).right.replace("px", "")) + delta) + "px";
this.svgCanvas.runExtensions('workareaResized');
}

Expand Down

0 comments on commit e572058

Please sign in to comment.