1 line
13 KiB
Plaintext
1 line
13 KiB
Plaintext
|
{"version":3,"file":"ext-overview_window.js","sources":["../../../src/editor/extensions/ext-overview_window.js"],"sourcesContent":["/**\n * @file ext-overview_window.js\n *\n * @license MIT\n *\n * @copyright 2013 James Sacksteder\n *\n */\nexport default {\n name: 'overview_window',\n init ({$, isChrome, isIE}) {\n const overviewWindowGlobals = {};\n // Disabled in Chrome 48-, see https://github.com/SVG-Edit/svgedit/issues/26 and\n // https://code.google.com/p/chromium/issues/detail?id=565120.\n if (isChrome()) {\n const verIndex = navigator.userAgent.indexOf('Chrome/') + 7;\n const chromeVersion = Number.parseInt(navigator.userAgent.substring(verIndex));\n if (chromeVersion < 49) {\n return undefined;\n }\n }\n\n // Define and insert the base html element.\n const propsWindowHtml =\n '<div id=\"overview_window_content_pane\" style=\"width:100%; ' +\n 'word-wrap:break-word; display:inline-block; margin-top:20px;\">' +\n '<div id=\"overview_window_content\" style=\"position:relative; ' +\n 'left:12px; top:0px;\">' +\n '<div style=\"background-color:#A0A0A0; display:inline-block; ' +\n 'overflow:visible;\">' +\n '<svg id=\"overviewMiniView\" width=\"150\" height=\"100\" x=\"0\" ' +\n 'y=\"0\" viewBox=\"0 0 4800 3600\" ' +\n 'xmlns=\"http://www.w3.org/2000/svg\" ' +\n 'xmlns:xlink=\"http://www.w3.org/1999/xlink\">' +\n '<use x=\"0\" y=\"0\" xlink:href=\"#svgroot\"> </use>' +\n '</svg>' +\n '<div id=\"overview_window_view_box\" style=\"min-width:50px; ' +\n 'min-height:50px; position:absolute; top:30px; left:30px; ' +\n 'z-index:5; background-color:rgba(255,0,102,0.3);\">' +\n '</div>' +\n '</div>' +\n '</div>' +\n '</div>';\n $('#sidepanels').append(propsWindowHtml);\n\n // Define dynamic animation of the view box.\n const updateViewBox = function () {\n const portHeight = Number.parseFloat($('#workarea').css('height'));\n const portWidth = Number.parseFloat($('#workarea').css('width'));\n const portX = $('#workarea').scrollLeft();\n const portY = $('#workarea').scrollTop();\n const windowWidth = Number.parseFloat($('#svgcanvas').css('width'));\n const windowHeight = Number.parseFloat($('#svgcanvas').css('height'));\n const overviewWidth = $('#overviewMiniView').attr('width');\n const overviewHeight = $('#overviewMiniView').attr('height');\n\n const viewBoxX = portX / windowWidth * overviewWidth;\n const viewBoxY = portY / windowHeight * overviewHeight;\n const viewBoxWidth = portWidth / windowWidth * overviewWidth;\n const viewBoxHeight = portHeight / windowHeight * overviewHeight;\n\n $('#overview_window_view_box').css('min-width', viewBoxWidth + 'px');\n $('#overview_window_view_box').css('min-height', viewBoxHeight + 'px');\n $('#overview_window_view_box').css('top', viewBoxY + 'px');\n $('#overview_window_view_box').css('left', viewBoxX + 'px');\n };\n $('#workarea').scroll(function () {\n if (!(overviewWindowGlobals.viewBoxDragging)) {\n updateViewBox();\n }\n });\n $('#workarea').resize(updateViewBox);\n updateViewBox();\n\n // Compensate for changes in zoom and canvas size.\n const updateViewDimensions = function () {\n const viewWidth = $('#svgroot').attr('width');\n const viewHeight = $('#svgroot').attr('height');\n\n let viewX = 640;\n let viewY = 480;\n if (isIE()) {\n // This has only been tested with Firefox 10 and IE 9 (without chrome frame).\n // I am not sure if if is Firefox or IE that is being non compliant here.\n // Either way the one that is noncompliant may become more compliant later.\n // TAG:HACK\n // TAG:VERSION_DEPENDENT\n // TAG:BROWSER_SNIFFING\n viewX = 0;\n viewY = 0;\n }\n\n const svgWidthOld = $('#overviewMiniView').attr('width');\n
|