Skip to content

Commit f7bd38a

Browse files
authored
(#109) Provide zoom type to hide negative coordinate space (#126)
1 parent 2e9e4c3 commit f7bd38a

File tree

18 files changed

+916
-128
lines changed

18 files changed

+916
-128
lines changed

LICENSE

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,38 @@
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201201
limitations under the License.
202+
203+
------------------------------------------------------------------------------------
204+
This product bundles various third-party components under other open source licenses.
205+
This section summarizes those components and their licenses.
206+
------------------------------------------------------------------------------------
207+
208+
d3-zoom extension
209+
210+
Copyright 2010-2016 Mike Bostock
211+
All rights reserved.
212+
213+
Redistribution and use in source and binary forms, with or without modification,
214+
are permitted provided that the following conditions are met:
215+
216+
* Redistributions of source code must retain the above copyright notice, this
217+
list of conditions and the following disclaimer.
218+
219+
* Redistributions in binary form must reproduce the above copyright notice,
220+
this list of conditions and the following disclaimer in the documentation
221+
and/or other materials provided with the distribution.
222+
223+
* Neither the name of the author nor the names of contributors may be used to
224+
endorse or promote products derived from this software without specific prior
225+
written permission.
226+
227+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
228+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
229+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
230+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
231+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
232+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
233+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
234+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
235+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
236+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

canvas_modules/common-canvas/src/common-canvas/canvas-controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export default class CanvasController {
7979
enableDisplayFullLabelOnHover: false,
8080
enableDropZoneOnExternalDrag: false,
8181
enableZoomIntoSubFlows: false,
82+
enableZoomType: "Regular",
8283
enableSaveZoom: "None",
8384
enableSnapToGridType: "None",
8485
enableSnapToGridX: null,

canvas_modules/common-canvas/src/common-canvas/constants/canvas-constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ _defineConstant("NOTIFICATION_ICON", "notificationCounterIcon");
3434

3535
_defineConstant("DEFAULT_NOTIFICATION_HEADER", "Notifications");
3636

37-
_defineConstant("MOUSE_INTERACTION", "Mouse");
38-
_defineConstant("TRACKPAD_INTERACTION", "Trackpad");
37+
_defineConstant("INTERACTION_MOUSE", "Mouse");
38+
_defineConstant("INTERACTION_TRACKPAD", "Trackpad");
3939

4040
_defineConstant("LINK_TYPE_CURVE", "Curve");
4141
_defineConstant("LINK_TYPE_ELBOW", "Elbow");
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2017-2020 IBM Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
module.exports = {
17+
extends: "eslint-config-canvas",
18+
rules: {
19+
// Allow snake_case, but only for object properties e.g. myObj.param_name
20+
"camelcase": [
21+
"error",
22+
{ "properties": "never" }
23+
],
24+
"max-len": [2, 180, 4],
25+
"id-length": ["error", { "min": 1 }],
26+
"indent": "off",
27+
"object-curly-spacing": "off",
28+
"no-shadow": "off",
29+
"no-invalid-this": "off",
30+
"consistent-this": "off",
31+
"no-nested-ternary": "off",
32+
"one-var": "off",
33+
"sort-vars": "off",
34+
"prefer-rest-params": "off",
35+
"no-eq-null": "off",
36+
"eqeqeq": "off",
37+
"newline-per-chained-call": "off",
38+
"one-var-declaration-per-line": "off",
39+
"no-param-reassign": "off",
40+
"no-implicit-coercion": "off",
41+
"brace-style": "off",
42+
"curly": "off",
43+
"no-unused-expressions": "off",
44+
"no-sequences": "off",
45+
"no-return-assign": "off",
46+
"max-len": "off",
47+
"prefer-spread": "off",
48+
"no-bitwise": "off",
49+
"sort-imports": "off",
50+
"no-undef": "off"
51+
},
52+
env: {
53+
jest: true
54+
},
55+
parserOptions: {
56+
"sourceType": "module"
57+
}
58+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright 2010-2016 Mike Bostock
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
* Neither the name of the author nor the names of contributors may be used to
15+
endorse or promote products derived from this software without specific prior
16+
written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default function(x) {
2+
return function() {
3+
return x;
4+
};
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default function ZoomEvent(target, type, transform) {
2+
this.target = target;
3+
this.type = type;
4+
this.transform = transform;
5+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {default as zoom} from "./zoom.js";
2+
export {default as zoomTransform, identity as zoomIdentity} from "./transform.js";
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {event} from "d3-selection";
2+
3+
export function nopropagation() {
4+
event.stopImmediatePropagation();
5+
}
6+
7+
export default function() {
8+
event.preventDefault();
9+
event.stopImmediatePropagation();
10+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
export function Transform(k, x, y) {
2+
this.k = k;
3+
this.x = x;
4+
this.y = y;
5+
}
6+
7+
Transform.prototype = {
8+
constructor: Transform,
9+
scale: function(k) {
10+
return k === 1 ? this : new Transform(this.k * k, this.x, this.y);
11+
},
12+
translate: function(x, y) {
13+
return x === 0 & y === 0 ? this : new Transform(this.k, this.x + this.k * x, this.y + this.k * y);
14+
},
15+
apply: function(point) {
16+
return [point[0] * this.k + this.x, point[1] * this.k + this.y];
17+
},
18+
applyX: function(x) {
19+
return x * this.k + this.x;
20+
},
21+
applyY: function(y) {
22+
return y * this.k + this.y;
23+
},
24+
invert: function(location) {
25+
return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k];
26+
},
27+
invertX: function(x) {
28+
return (x - this.x) / this.k;
29+
},
30+
invertY: function(y) {
31+
return (y - this.y) / this.k;
32+
},
33+
rescaleX: function(x) {
34+
return x.copy().domain(x.range().map(this.invertX, this).map(x.invert, x));
35+
},
36+
rescaleY: function(y) {
37+
return y.copy().domain(y.range().map(this.invertY, this).map(y.invert, y));
38+
},
39+
toString: function() {
40+
return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
41+
}
42+
};
43+
44+
export var identity = new Transform(1, 0, 0);
45+
46+
transform.prototype = Transform.prototype;
47+
48+
export default function transform(node) {
49+
while (!node.__zoom) if (!(node = node.parentNode)) return identity;
50+
return node.__zoom;
51+
}

0 commit comments

Comments
 (0)