merge master

This commit is contained in:
黄通 2018-11-01 17:02:26 +08:00
commit 21e9be2e74
7 changed files with 53 additions and 47 deletions

View File

@ -1,3 +1,4 @@
# ChangeLog
---

View File

@ -1,14 +1,17 @@
(function () {
// filtering
const $query = $('#query');
var $query = $('#query');
function filter() {
const str = $query.val();
var str = $query.val();
if (!str) {
$('.demo-thumbnail').show();
} else {
$('.demo-thumbnail').each(function () {
const $thumbnail = $(this);
const basename = $thumbnail.data('basename');
var $thumbnail = $(this);
var basename = $thumbnail.data('basename');
if (basename.indexOf(str) === -1) {
$thumbnail.hide();
} else {
@ -17,28 +20,24 @@
});
}
}
$query.on('input', _.debounce(filter));
// router
let currentId;
const $code = $('#code');
const htmlEditor = CodeMirror.fromTextArea($code[0], {
$query.on('input', _.debounce(filter)); // router
var currentId;
var $code = $('#code');
var htmlEditor = CodeMirror.fromTextArea($code[0], {
mode: "text/html",
extraKeys: {
'Ctrl-Space': 'autocomplete'
},
foldGutter: true,
gutters: [
'CodeMirror-linenumbers',
'CodeMirror-foldgutter'
],
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
lineNumbers: true,
lineWrapping: false
});
const $docContainer = $('#doc-container');
const $chartPanel = $('#chart-panel');
const $codePanel = $('#code-panel');
var $docContainer = $('#doc-container');
var $chartPanel = $('#chart-panel');
var $codePanel = $('#code-panel');
function syncCode(code) {
$chartPanel.html('<iframe class="chart-frame" frameborder="0"></iframe>');
@ -47,59 +46,58 @@
}
routie({
'/:id': id => {
'/:id': function id(_id) {
$docContainer.show();
const $htmlCode = $(`#code-${id}`);
const code = $htmlCode.text();
syncCode(code)
var $htmlCode = $("#code-" + _id);
var code = $htmlCode.text();
syncCode(code);
},
'': () => {
'': function _(id) {
$docContainer.hide();
}
});
}); // resizable
// resizable
$codePanel.resizable({
handleSelector: '#resize-handler',
resizeWidthFrom: 'right',
resizeHeight: false,
onDragStart() {
onDragStart: function onDragStart() {
$docContainer.css('pointer-events', 'none');
$docContainer.css('cursor', 'col-resize');
$codePanel.find('.CodeMirror-gutter-elt').css('cursor', 'col-resize');
},
onDragEnd() {
onDragEnd: function onDragEnd() {
$docContainer.css('pointer-events', 'auto');
$docContainer.css('cursor', 'default');
$codePanel.find('.CodeMirror-gutter-elt').css('cursor', 'default');
},
});
}
}); // copy code
// copy code
const BTN_COPY_SELECTOR = '#copy-code';
const clipboard = new Clipboard(BTN_COPY_SELECTOR, {
text: () => htmlEditor.getValue(),
var BTN_COPY_SELECTOR = '#copy-code';
var clipboard = new Clipboard(BTN_COPY_SELECTOR, {
text: function text() {
return htmlEditor.getValue();
}
});
let timer;
clipboard.on('success', e => {
var timer;
clipboard.on('success', function (e) {
e.clearSelection();
$(BTN_COPY_SELECTOR).text('Succeed!');
clearTimeout(timer);
timer = setTimeout(() => {
timer = setTimeout(function () {
$(BTN_COPY_SELECTOR).text('Copy');
}, 2000);
});
clipboard.on('error', e => {
clipboard.on('error', function (e) {
e.clearSelection();
$(BTN_COPY_SELECTOR).text('Failed!');
clearTimeout(timer);
timer = setTimeout(() => {
timer = setTimeout(function () {
$(BTN_COPY_SELECTOR).text('Copy');
}, 2000);
});
}); // run code
// run code
$('#execute').on('click', () => {
$('#execute').on('click', function () {
syncCode(htmlEditor.getValue());
});
})();
})();

View File

@ -1,6 +1,6 @@
{
"name": "@antv/g6",
"version": "2.1.4-beta.3",
"version": "2.1.4",
"description": "graph visualization frame work",
"main": "build/g6.js",
"homepage": "https://github.com/antvis/g6",

View File

@ -53,7 +53,7 @@ class Controller extends Base {
_initEventStates() {
this._pressing = false;
this._dragging = false;
this._currentEventObj = null;
this._currentEventObj = {};
this._dragEventObj = {};
}
// register all native dom events

View File

@ -68,12 +68,13 @@ class Node extends Item {
const { centerX, centerY } = bbox;
const x1 = x - centerX;
const y1 = y - centerY;
const anchor = this.shapeObj.anchor || {};
const shapeObj = this.shapeObj;
const anchor = shapeObj.anchor || {};
const defaultIntersectBox = this.defaultIntersectBox;
let points = [];
if (Util.isEmpty(anchorPoints)) {
// get link point if there are no default anchors
const intersectBox = anchor.intersectBox || anchor.type || defaultIntersectBox;
const intersectBox = shapeObj.intersectBox || anchor.intersectBox || anchor.type || defaultIntersectBox;
switch (intersectBox) {
case 'rect':

View File

@ -5,7 +5,13 @@
*/
const MAX_LEVEL = 5;
const Util = require('@antv/util/lib');
Math.sign = function(x) {
x = +x;
if (x === 0 || isNaN(x)) {
return x;
}
return x > 0 ? 1 : -1;
};
const BaseUtil = {
...Util,
throttle: require('lodash/throttle'),

View File

@ -1 +1 @@
module.exports = '2.1.4-beta.3';
module.exports = '2.1.4';