- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
/* globals jQuery */
|
2013-09-23 18:55:52 +00:00
|
|
|
/*
|
|
|
|
* ext-overview_window.js
|
|
|
|
*
|
|
|
|
* Licensed under the MIT License
|
|
|
|
*
|
|
|
|
* Copyright(c) 2013 James Sacksteder
|
|
|
|
*
|
|
|
|
*/
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
import svgEditor from '../svg-editor.js';
|
2013-09-23 18:55:52 +00:00
|
|
|
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
svgEditor.addExtension('overview_window', function ({isChrome, isIE}) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const $ = jQuery;
|
|
|
|
const overviewWindowGlobals = {};
|
2018-05-18 04:54:31 +00:00
|
|
|
// Disabled in Chrome 48-, see https://github.com/SVG-Edit/svgedit/issues/26 and
|
|
|
|
// https://code.google.com/p/chromium/issues/detail?id=565120.
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
if (isChrome()) {
|
2018-05-18 03:25:45 +00:00
|
|
|
const verIndex = navigator.userAgent.indexOf('Chrome/') + 7;
|
|
|
|
const chromeVersion = parseInt(navigator.userAgent.substring(verIndex), 10);
|
2018-05-18 04:54:31 +00:00
|
|
|
if (chromeVersion < 49) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-12-04 01:25:18 +00:00
|
|
|
|
2018-05-18 04:54:31 +00:00
|
|
|
// Define and insert the base html element.
|
2018-05-18 03:25:45 +00:00
|
|
|
const propsWindowHtml =
|
2018-05-18 04:54:31 +00:00
|
|
|
'<div id="overview_window_content_pane" style="width:100%; word-wrap:break-word; display:inline-block; margin-top:20px;">' +
|
|
|
|
'<div id="overview_window_content" style="position:relative; left:12px; top:0px;">' +
|
|
|
|
'<div style="background-color:#A0A0A0; display:inline-block; overflow:visible;">' +
|
|
|
|
'<svg id="overviewMiniView" width="150" height="100" x="0" y="0" viewBox="0 0 4800 3600" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' +
|
|
|
|
'<use x="0" y="0" xlink:href="#svgroot"> </use>' +
|
|
|
|
'</svg>' +
|
|
|
|
'<div id="overview_window_view_box" style="min-width:50px; min-height:50px; position:absolute; top:30px; left:30px; z-index:5; background-color:rgba(255,0,102,0.3);">' +
|
|
|
|
'</div>' +
|
|
|
|
'</div>' +
|
|
|
|
'</div>' +
|
|
|
|
'</div>';
|
|
|
|
$('#sidepanels').append(propsWindowHtml);
|
2014-02-16 03:21:15 +00:00
|
|
|
|
2018-05-18 04:54:31 +00:00
|
|
|
// Define dynamic animation of the view box.
|
2018-05-18 03:25:45 +00:00
|
|
|
const updateViewBox = function () {
|
|
|
|
const portHeight = parseFloat($('#workarea').css('height'));
|
|
|
|
const portWidth = parseFloat($('#workarea').css('width'));
|
|
|
|
const portX = $('#workarea').scrollLeft();
|
|
|
|
const portY = $('#workarea').scrollTop();
|
|
|
|
const windowWidth = parseFloat($('#svgcanvas').css('width'));
|
|
|
|
const windowHeight = parseFloat($('#svgcanvas').css('height'));
|
|
|
|
const overviewWidth = $('#overviewMiniView').attr('width');
|
|
|
|
const overviewHeight = $('#overviewMiniView').attr('height');
|
2018-05-16 00:53:27 +00:00
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
const viewBoxX = portX / windowWidth * overviewWidth;
|
|
|
|
const viewBoxY = portY / windowHeight * overviewHeight;
|
|
|
|
const viewBoxWidth = portWidth / windowWidth * overviewWidth;
|
|
|
|
const viewBoxHeight = portHeight / windowHeight * overviewHeight;
|
2018-05-16 00:53:27 +00:00
|
|
|
|
2018-05-18 04:54:31 +00:00
|
|
|
$('#overview_window_view_box').css('min-width', viewBoxWidth + 'px');
|
|
|
|
$('#overview_window_view_box').css('min-height', viewBoxHeight + 'px');
|
|
|
|
$('#overview_window_view_box').css('top', viewBoxY + 'px');
|
|
|
|
$('#overview_window_view_box').css('left', viewBoxX + 'px');
|
|
|
|
};
|
|
|
|
$('#workarea').scroll(function () {
|
|
|
|
if (!(overviewWindowGlobals.viewBoxDragging)) {
|
|
|
|
updateViewBox();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('#workarea').resize(updateViewBox);
|
|
|
|
updateViewBox();
|
2018-05-16 00:53:27 +00:00
|
|
|
|
2018-05-18 04:54:31 +00:00
|
|
|
// Compensate for changes in zoom and canvas size.
|
2018-05-18 03:25:45 +00:00
|
|
|
const updateViewDimensions = function () {
|
|
|
|
const viewWidth = $('#svgroot').attr('width');
|
|
|
|
const viewHeight = $('#svgroot').attr('height');
|
2018-05-16 00:53:27 +00:00
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
let viewX = 640;
|
|
|
|
let viewY = 480;
|
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
|
|
|
if (isIE()) {
|
2018-05-18 04:54:31 +00:00
|
|
|
// This has only been tested with Firefox 10 and IE 9 (without chrome frame).
|
|
|
|
// I am not sure if if is Firefox or IE that is being non compliant here.
|
|
|
|
// Either way the one that is noncompliant may become more compliant later.
|
|
|
|
// TAG:HACK
|
|
|
|
// TAG:VERSION_DEPENDENT
|
|
|
|
// TAG:BROWSER_SNIFFING
|
|
|
|
viewX = 0;
|
|
|
|
viewY = 0;
|
|
|
|
}
|
2018-05-16 00:53:27 +00:00
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
const svgWidthOld = $('#overviewMiniView').attr('width');
|
|
|
|
const svgHeightNew = viewHeight / viewWidth * svgWidthOld;
|
2018-05-18 04:54:31 +00:00
|
|
|
$('#overviewMiniView').attr('viewBox', viewX + ' ' + viewY + ' ' + viewWidth + ' ' + viewHeight);
|
|
|
|
$('#overviewMiniView').attr('height', svgHeightNew);
|
|
|
|
updateViewBox();
|
|
|
|
};
|
|
|
|
updateViewDimensions();
|
2018-05-16 00:53:27 +00:00
|
|
|
|
2018-05-18 04:54:31 +00:00
|
|
|
// Set up the overview window as a controller for the view port.
|
|
|
|
overviewWindowGlobals.viewBoxDragging = false;
|
2018-05-18 03:25:45 +00:00
|
|
|
const updateViewPortFromViewBox = function () {
|
|
|
|
const windowWidth = parseFloat($('#svgcanvas').css('width'));
|
|
|
|
const windowHeight = parseFloat($('#svgcanvas').css('height'));
|
|
|
|
const overviewWidth = $('#overviewMiniView').attr('width');
|
|
|
|
const overviewHeight = $('#overviewMiniView').attr('height');
|
|
|
|
const viewBoxX = parseFloat($('#overview_window_view_box').css('left'));
|
|
|
|
const viewBoxY = parseFloat($('#overview_window_view_box').css('top'));
|
2013-09-23 18:55:52 +00:00
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
const portX = viewBoxX / overviewWidth * windowWidth;
|
|
|
|
const portY = viewBoxY / overviewHeight * windowHeight;
|
2018-05-16 00:53:27 +00:00
|
|
|
|
2018-05-18 04:54:31 +00:00
|
|
|
$('#workarea').scrollLeft(portX);
|
|
|
|
$('#workarea').scrollTop(portY);
|
|
|
|
};
|
|
|
|
$('#overview_window_view_box').draggable({
|
|
|
|
containment: 'parent',
|
|
|
|
drag: updateViewPortFromViewBox,
|
2018-05-18 03:25:45 +00:00
|
|
|
start () { overviewWindowGlobals.viewBoxDragging = true; },
|
|
|
|
stop () { overviewWindowGlobals.viewBoxDragging = false; }
|
2018-05-18 04:54:31 +00:00
|
|
|
});
|
|
|
|
$('#overviewMiniView').click(function (evt) {
|
|
|
|
// Firefox doesn't support evt.offsetX and evt.offsetY.
|
2018-05-18 03:25:45 +00:00
|
|
|
const mouseX = (evt.offsetX || evt.originalEvent.layerX);
|
|
|
|
const mouseY = (evt.offsetY || evt.originalEvent.layerY);
|
|
|
|
const overviewWidth = $('#overviewMiniView').attr('width');
|
|
|
|
const overviewHeight = $('#overviewMiniView').attr('height');
|
|
|
|
const viewBoxWidth = parseFloat($('#overview_window_view_box').css('min-width'));
|
|
|
|
const viewBoxHeight = parseFloat($('#overview_window_view_box').css('min-height'));
|
2018-05-16 00:53:27 +00:00
|
|
|
|
2018-05-18 03:25:45 +00:00
|
|
|
let viewBoxX = mouseX - 0.5 * viewBoxWidth;
|
|
|
|
let viewBoxY = mouseY - 0.5 * viewBoxHeight;
|
2018-05-18 04:54:31 +00:00
|
|
|
// deal with constraints
|
|
|
|
if (viewBoxX < 0) {
|
|
|
|
viewBoxX = 0;
|
|
|
|
}
|
|
|
|
if (viewBoxY < 0) {
|
|
|
|
viewBoxY = 0;
|
|
|
|
}
|
|
|
|
if (viewBoxX + viewBoxWidth > overviewWidth) {
|
|
|
|
viewBoxX = overviewWidth - viewBoxWidth;
|
|
|
|
}
|
|
|
|
if (viewBoxY + viewBoxHeight > overviewHeight) {
|
|
|
|
viewBoxY = overviewHeight - viewBoxHeight;
|
|
|
|
}
|
2018-05-16 00:53:27 +00:00
|
|
|
|
2018-05-18 04:54:31 +00:00
|
|
|
$('#overview_window_view_box').css('top', viewBoxY + 'px');
|
|
|
|
$('#overview_window_view_box').css('left', viewBoxX + 'px');
|
|
|
|
updateViewPortFromViewBox();
|
|
|
|
});
|
2018-05-16 00:53:27 +00:00
|
|
|
|
2018-05-18 04:54:31 +00:00
|
|
|
return {
|
|
|
|
name: 'overview window',
|
|
|
|
canvasUpdated: updateViewDimensions,
|
|
|
|
workareaResized: updateViewBox
|
|
|
|
};
|
2013-09-23 18:55:52 +00:00
|
|
|
});
|