Skip to content
This repository was archived by the owner on Jul 29, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
static
.github
Makefile
*.json
*.lock
*.log
webpack.config.ts
18 changes: 0 additions & 18 deletions .eslintrc

This file was deleted.

27 changes: 27 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const OFF = 0;
const ERROR = 2;

module.exports = {
env: {
browser: true,
es6: true,
node: true,
jest: true,
},

parserOptions: {
sourceType: "module",
},

extends: ["eslint:recommended"],

rules: {
"no-cond-assign": OFF,
"no-floating-decimal": ERROR,
"no-trailing-spaces": ERROR,
"no-multiple-empty-lines": [ERROR, { max: 2, maxEOF: 0 }],
"eol-last": ERROR,
semi: ERROR,
complexity: [ERROR, { max: 18 }],
},
};
File renamed without changes.
40 changes: 13 additions & 27 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
Copyright (c) 2016, Quantmind
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of d3-canvas-transition nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copyright 2020 Quantmind

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE
28 changes: 0 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,3 @@
[![CircleCI](https://circleci.com/gh/quantmind/d3-canvas-transition.svg?style=svg)](https://circleci.com/gh/quantmind/d3-canvas-transition)
[![Dependency Status](https://david-dm.org/quantmind/d3-canvas-transition.svg)](https://david-dm.org/quantmind/d3-canvas-transition)
[![devDependency Status](https://david-dm.org/quantmind/d3-canvas-transition/dev-status.svg)](https://david-dm.org/quantmind/d3-canvas-transition#info=devDependencies)

**ALPHA - USE IT WITH CARE**

This is a [d3 plugin](https://bost.ocks.org/mike/d3-plugin/) for drawing on
svg and canvas using the same [d3-transition](https://github.com/d3/d3-transition) API.

## Installing

If you use [NPM](https://www.npmjs.com/package/d3-canvas-transition), ``npm install d3-canvas-transition``.
Otherwise, download the [latest release](https://github.com/quantmind/d3-canvas-transition/releases).
You can also load directly from [giottojs.org](https://giottojs.org),
as a [standalone library](https://giottojs.org/latest/d3-canvas-transition.js) or
[unpkg](https://unpkg.com/d3-canvas-transition/).
AMD, CommonJS, and vanilla environments are supported. In vanilla, a d3 global is exported.
Try [d3-canvas-transition](https://runkit.com/npm/d3-canvas-transition) in your browser.
```javascript
<script src="https://d3js.org/d3-collection.v1.min.js"></script>
<script src="https://d3js.org/d3-color.v1.min.js"></script>
<script src="https://d3js.org/d3-selection.v1.min.js"></script>
<script src="https://d3js.org/d3-timer.v1.min.js"></script>
<script src="https://giottojs.org/latest/d3-canvas-transition.min.js"></script>
<body>
<canvas id="hi" width="400" height="400"></canvas>
<script>
var canvas = d3.select('#hi').canvas();
</script>
```
For examples check [lsbardel blocks](http://bl.ocks.org/lsbardel)
16 changes: 16 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"rootDir": ".",
"automock": false,
"testEnvironment": "jsdom",
"testMatch": ["<rootDir>/test/*-test.js"],
"coverageReporters": ["json", "html", "lcov", "text", "text-summary"],
"coveragePathIgnorePatterns": ["node_modules", "dist"],
"coverageThreshold": {
"global": {
"branches": 10,
"functions": 10,
"lines": 10,
"statements": 10
}
}
}
143 changes: 72 additions & 71 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,75 +1,76 @@
{
"version": "0.3.7",
"name": "d3-canvas-transition",
"title": "d3-canvas-transition",
"description": "Animated transitions for D3 selections on svg and canvas",
"homepage": "https://github.com/quantmind/d3-canvas-transition",
"repository": {
"type": "git",
"url": "git+https://github.com/quantmind/d3-canvas-transition.git"
},
"keywords": [
"d3",
"d3-module",
"svg",
"canvas",
"transition",
"animation"
"version": "0.3.7",
"name": "d3-canvas-transition",
"title": "d3-canvas-transition",
"description": "Animated transitions for D3 selections on svg and canvas",
"homepage": "https://github.com/quantmind/d3-canvas-transition",
"repository": {
"type": "git",
"url": "git+https://github.com/quantmind/d3-canvas-transition.git"
},
"keywords": [
"d3",
"d3-module",
"svg",
"canvas",
"transition",
"animation"
],
"license": "BSD-3-Clause",
"author": {
"name": "quantmind.com",
"email": "message@quantmind.com"
},
"main": "build/d3-canvas-transition.js",
"jsnext:main": "ui/js/main",
"module": "ui/js/main",
"lint-staged": {
"*.{ts,js}": [
"yarn fix"
],
"license": "BSD-3-Clause",
"author": {
"name": "quantmind.com",
"email": "message@quantmind.com"
},
"main": "build/d3-canvas-transition.js",
"jsnext:main": "ui/js/main",
"module": "ui/js/main",
"dependencies": {
"d3-collection": "1.0",
"d3-color": "1.0",
"d3-selection": "1.1",
"d3-timer": "1.0"
},
"devDependencies": {
"babel-preset-es2015": "6.24",
"babel-preset-es2015-rollup": "3.0",
"babel-tape-runner": "2.0",
"babelify": "7.3",
"browserify": "14.4",
"canvas": "1.6",
"d3-axis": "1.0",
"d3-dispatch": "1.0",
"d3-ease": "1.0",
"d3-interpolate": "1.1",
"d3-scale": "1.0",
"d3-shape": "1.2",
"d3-transition": "1.1",
"eslint": "4.2",
"faucet": "0.0",
"jsdom": "9.9",
"package-preamble": "0.1",
"publish": "0.6",
"rollup": "0.45",
"rollup-plugin-babel": "2.7",
"rollup-plugin-json": "2.3",
"rollup-plugin-sourcemaps": "0.4",
"tape": "4.7",
"uglify-js": "3.0"
},
"scripts": {
"lint": "eslint index.js rollup.config.js src test",
"unit": "babel-tape-runner `find test -name '*-test.js'` | faucet",
"test": "npm run-script lint && npm run-script unit",
"rollup": "rollup -c --banner \"$(preamble)\"",
"minify": "uglifyjs --preamble \"$(preamble)\" build/d3-canvas-transition.js -c -m -o build/d3-canvas-transition.min.js",
"build": "npm run-script rollup && npm run-script minify",
"prepublish": "npm run-script rollup && npm run-script minify",
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git tag -am \"Release $VERSION.\" v${VERSION} && git push --tags && mkdir -p ../giottojs.org/latest && mkdir -p ../giottojs.org/d3-canvas-transition/${VERSION} && cp build/* ../giottojs.org/d3-canvas-transition/${VERSION}/ && cp build/* ../giottojs.org/latest/ && cd ../giottojs.org && git add d3-canvas-transition/${VERSION} latest && git commit -a -m \"d3-canvas-transition ${VERSION}\" && git push",
"release": "publish"
},
"babel": {
"presets": [
"es2015"
]
"*.{json,css,scss}": [
"prettier --write"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"post-commit": "git update-index --again"
}
},
"dependencies": {
"d3-collection": "1.0.7",
"d3-color": "1.4.1",
"d3-selection": "1.4.1",
"d3-timer": "1.0.10"
},
"devDependencies": {
"canvas": "2.6.1",
"d3-axis": "1.0.12",
"d3-dispatch": "1.0.6",
"d3-ease": "1.0.6",
"d3-interpolate": "1.4.0",
"d3-scale": "3.2.1",
"d3-shape": "1.3.7",
"d3-transition": "1.3.2",
"eslint": "^7.4.0",
"eslint-plugin-prettier": "^3.1.4",
"faucet": "0.0",
"husky": "^4.2.5",
"jest": "^26.1.0",
"jsdom": "16.2.2",
"lint-staged": "^10.2.11",
"prettier": "^2.0.5",
"publish": "0.6",
"rollup": "2.18.2",
"rollup-plugin-sourcemaps": "0.6.2"
},
"scripts": {
"lint": "eslint './src/*' './test/*'",
"fix": "eslint './src/*' './test/*' --fix",
"test": "jest",
"rollup": "rollup -c",
"build": "export NODE_ENV=production && npm run-script rollup",
"release": "publish"
}
}
19 changes: 8 additions & 11 deletions src/attrs/path.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
export default function (p) {
function cp() {
return canvasPath(p, arguments);
}

function cp () {
return canvasPath(p, arguments);
}

return cp;
return cp;
}


function canvasPath (p, parameters) {

return function () {
p.apply(this, parameters);
};
function canvasPath(p, parameters) {
return function () {
p.apply(this, parameters);
};
}
8 changes: 4 additions & 4 deletions src/attrs/set.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function (node, attr, value) {
var current = node.attrs.get(attr);
if (current === value) return false;
node.attrs.set(attr, value);
return true;
var current = node.attrs.get(attr);
if (current === value) return false;
node.attrs.set(attr, value);
return true;
}
Loading