Skip to content

Commit

Permalink
fix: conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
dengfuping committed Oct 25, 2019
2 parents 2cffa1c + 3850e68 commit 737b2c3
Show file tree
Hide file tree
Showing 29 changed files with 245 additions and 144 deletions.
4 changes: 0 additions & 4 deletions gatsby-browser.js

This file was deleted.

8 changes: 2 additions & 6 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@ module.exports = {
{
resolve: '@antv/gatsby-theme-antv',
options: {
pagesPath: './site/pages',
GATrackingId: `UA-148148901-3`,
primaryColor: '#1890ff',
pathPrefix: '/g',
},
},
],
siteMetadata: {
title: 'G',
siteUrl: 'https://antvis.github.io/g',
description: 'A powerful rendering engine for AntV providing canvas and svg draw',
githubUrl: 'https://github.com/antvis/g',
languages: {
langs: ['en', 'zh'],
defaultLangKey: 'en',
},
docs: [
{
slug: 'guide',
Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
"postversion": "npm run build",
"publish": "lerna publish",
"publish-beta": "npm run pre-publish && lerna publish --dist-tag beta",
"site:build": "gatsby build",
"site:develop": "gatsby develop",
"site:clean": "gatsby clean"
"start": "npm run site:develop",
"site:develop": "gatsby develop --open",
"site:build": "npm run site:clean && gatsby build --prefix-paths",
"site:clean": "gatsby clean",
"site:deploy": "npm run site:build && gh-pages -d public"
},
"lint-staged": {
"**/*.{js,ts}": [
Expand All @@ -44,7 +46,7 @@
}
},
"dependencies": {
"@antv/gatsby-theme-antv": "^0.2.7",
"@antv/gatsby-theme-antv": "^0.4.0",
"@antv/istanbul": "0.0.0",
"@antv/torch": "^1.0.0",
"gatsby": "^2.15.34",
Expand Down Expand Up @@ -75,6 +77,7 @@
"eslint-config-egg": "^7.1.0",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-html": "^5.0.0",
"gh-pages": "^2.1.1",
"git-contributor": "~1.0.8",
"husky": "^1.3.0",
"lerna": "^3.4.3",
Expand All @@ -91,4 +94,4 @@
"webpack": "^4.26.1",
"webpack-cli": "^3.1.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/g-base/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-base",
"version": "0.1.0-beta.4",
"version": "0.1.0-beta.5",
"description": "A common util collection for antv projects",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
27 changes: 23 additions & 4 deletions packages/g-base/src/abstract/container.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { IBase, IContainer, ICtor, IShape, IGroup, IElement, ICanvas } from '../interfaces';
import { ShapeBase } from '../types';
import BBox from '../bbox';
import { ShapeBase, BBox } from '../types';
import Timeline from '../animate/timeline';
import Element from './element';
import { isFunction, isObject, each, removeFromArray, upperFirst } from '../util/util';
Expand Down Expand Up @@ -134,7 +133,17 @@ abstract class Container extends Element implements IContainer {
minY = 0;
maxY = 0;
}
return BBox.fromRange(minX, minY, maxX, maxY);
const box = {
x: minX,
y: minY,
minX,
minY,
maxX,
maxY,
width: maxX - minX,
height: maxY - minY,
};
return box;
}

// 获取画布的包围盒
Expand Down Expand Up @@ -168,7 +177,17 @@ abstract class Container extends Element implements IContainer {
minY = 0;
maxY = 0;
}
return BBox.fromRange(minX, minY, maxX, maxY);
const box = {
x: minX,
y: minY,
minX,
minY,
maxX,
maxY,
width: maxX - minX,
height: maxY - minY,
};
return box;
}

abstract getShapeBase(): ShapeBase;
Expand Down
6 changes: 4 additions & 2 deletions packages/g-base/src/abstract/element.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { each, isEqual, isFunction, isNumber, isObject, isArray, noop, mix, upperFirst, uniqueId } from '@antv/util';
import { IElement, IShape, IGroup, ICanvas } from '../interfaces';
import { ClipCfg, ChangeType, OnFrame, ShapeAttrs, AnimateCfg, Animation } from '../types';
import { ClipCfg, ChangeType, OnFrame, ShapeAttrs, AnimateCfg, Animation, BBox } from '../types';
import { removeFromArray } from '../util/util';
import { multiplyMatrix, multiplyVec2, invert } from '../util/matrix';
import Base from './base';
import BBox from '../bbox';

const MATRIX = 'matrix';
const ARRAY_ATTRS = {
Expand Down Expand Up @@ -343,6 +342,7 @@ abstract class Element extends Base implements IElement {
setClip(clipCfg: ClipCfg) {
const preShape = this.get('clipShape');
if (preShape) {
// 将之前的 clipShape 销毁
preShape.destroy();
}
let clipShape = null;
Expand All @@ -359,11 +359,13 @@ abstract class Element extends Base implements IElement {
type: clipCfg.type,
isClipShape: true, // 增加一个标记
attrs: clipCfg.attrs,
canvas, // 设置 canvas
});
}
}
this.set('clipShape', clipShape);
this.onCanvasChange('clip');
return clipShape;
}

getClip(): IShape {
Expand Down
16 changes: 12 additions & 4 deletions packages/g-base/src/abstract/shape.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { IShape } from '../interfaces';
import { ShapeCfg, ShapeAttrs } from '../types';
import BBox from '../bbox';
import { ShapeCfg, ShapeAttrs, BBox } from '../types';
import Element from './element';
import { each, isArray } from '../util/util';
import { multiplyVec2 } from '../util/matrix';
Expand Down Expand Up @@ -59,7 +58,7 @@ abstract class AbstractShape extends Element implements IShape {
* 计算相对于画布的包围盒,默认等同于 bbox
* @return {BBox} 包围盒
*/
calculateCanvasBBox(): BBox {
calculateCanvasBBox() {
const bbox = this.getBBox();
const totalMatrix = this.getTotalMatrix();
// 如果没有任何矩阵,则等同于计算 bbox
Expand All @@ -74,7 +73,16 @@ abstract class AbstractShape extends Element implements IShape {
const maxX = Math.max(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]);
const minY = Math.min(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1]);
const maxY = Math.max(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1]);
return BBox.fromRange(minX, minY, maxX, maxY);
return {
x: minX,
y: minY,
minX,
minY,
maxX,
maxY,
width: maxX - minX,
height: maxY - minY,
};
}

/**
Expand Down
80 changes: 0 additions & 80 deletions packages/g-base/src/bbox.ts

This file was deleted.

8 changes: 4 additions & 4 deletions packages/g-base/src/event/event-contoller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ function emitDelegation(container, type, eventObj) {
const paths = eventObj.propagationPath;
const events = container.events;
// 至少有一个对象
for (let i = 1; i < paths.length; i++) {
const group = paths[i];
for (let i = 0; i < paths.length; i++) {
const element = paths[i];
// 暂定跟 name 绑定
const name = group.get('name');
const name = element.get('name');
if (name) {
const eventName = name + DELEGATION_SPLIT + type;
if (events[eventName]) {
eventObj.delegateTarget = container;
eventObj.currentTarget = group;
eventObj.currentTarget = element;
container.emit(eventName, eventObj);
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/g-base/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
const pkg = require('../package.json');

export const version = pkg.version;
export { default as BBox } from './bbox';
export { default as Event } from './event/graph-event';
export { default as Base } from './abstract/base';
export { default as AbstractCanvas } from './abstract/canvas';
Expand Down
16 changes: 13 additions & 3 deletions packages/g-base/src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { ShapeCfg, GroupCfg, ClipCfg, Point, ChangeType, AnimateCfg, ElementAttrs, OnFrame, ShapeBase } from './types';
import BBox from './bbox';
import {
ShapeCfg,
GroupCfg,
ClipCfg,
Point,
ChangeType,
AnimateCfg,
ElementAttrs,
OnFrame,
ShapeBase,
BBox,
} from './types';

export interface ICtor<T> {
new (cfg: any): T;
Expand Down Expand Up @@ -134,7 +144,7 @@ export interface IElement extends IBase {
* 获取包围盒,这个包围盒是相对于图形元素自己,不会计算 matrix
* @returns {BBox} 包围盒
*/
getBBox(): BBox;
getBBox();
/**
* 获取图形元素相对画布的包围盒,会计算从顶层到当前的 matrix
* @returns {BBox} 包围盒
Expand Down
11 changes: 11 additions & 0 deletions packages/g-base/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { IShape, ICtor } from './interfaces';

export type BBox = {
x: number;
y: number;
minX: number;
minY: number;
maxX: number;
maxY: number;
width: number;
height: number;
};

export type Point = {
x: number;
y: number;
Expand Down
6 changes: 1 addition & 5 deletions packages/g-base/tests/unit/index-spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { expect } from 'chai';
import { BBox, Event, AbstractCanvas, AbstractGroup, AbstractShape, Base, version } from '../../src/index';
import { Event, AbstractCanvas, AbstractGroup, AbstractShape, Base, version } from '../../src/index';

describe('Canvas index', () => {
it('BBox', () => {
expect(BBox).not.eql(undefined);
});

it('Event', () => {
expect(Event).not.eql(undefined);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/g-canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-canvas",
"version": "0.1.0-beta.4",
"version": "0.1.0-beta.5",
"description": "A canvas library which providing 2d",
"main": "lib/index.js",
"module": "esm/index.js",
Expand Down Expand Up @@ -55,8 +55,8 @@
},
"homepage": "https://github.com/antvis/g#readme",
"dependencies": {
"@antv/g-base": "^0.1.0-beta.4",
"@antv/g-math": "^0.1.0-beta.3",
"@antv/g-base": "^0.1.0-beta.5",
"@antv/g-math": "^0.1.0-beta.4",
"@antv/gl-matrix": "~2.7.1",
"@antv/path-util": "~2.0.3-beta.1",
"@antv/util": "~2.0.0"
Expand Down
1 change: 0 additions & 1 deletion packages/g-canvas/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Shape from './shape';
const pkg = require('../package.json');

export const version = pkg.version;
export { BBox } from '@antv/g-base';
export { Event } from '@antv/g-base';
export { default as Canvas } from './canvas';
export { default as Group } from './group';
Expand Down
Loading

0 comments on commit 737b2c3

Please sign in to comment.