Skip to content

Commit

Permalink
Merge branch 'master' into pr/7175
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 committed Apr 26, 2022
2 parents f927143 + 4b3f9a3 commit d8eb923
Show file tree
Hide file tree
Showing 80 changed files with 10,420 additions and 1,637 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# These are supported funding model platforms

github: [asturur]
github: [asturur, ShaMan123, melchiar]
patreon: fabricJS
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ about: Create a report with a reproducible test case in a JSFIDDLE, For anything
<!-- ISSUES THAT ARE NOT BUGS OR LACK A TEST CASE WILL BE CLOSED. -->
<!-- A good reproduction helps us understand better your issue, find the bug and fix it quickly so take the time to make it accurate and minimal -->
## Test Case
http://jsfiddle.net/fabricjs/Da7SP/
- [ ] [Browser Issue Template](https://jsfiddle.net/Lcp2h3nv/)
- [ ] [Node Issue Template](https://codesandbox.io/s/exciting-browser-ytb701)

## Information about environment
Nodejs or browser?
Expand Down
52 changes: 52 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
name: Pull Request
about: Creating a PR

---

<!--
Hi there!
Thanks for taking the time and putting the effort into making fabric better! 💖
Take a look at ./CONTRIBUTING.md for crucial instructions regarding local setup, testing etc.
https://github.com/fabricjs/fabric.js/blob/master/CONTRIBUTING.md
Adding tests that verify your fix and safegurad it from unwanted loss and changes is a MUST.
PRing is not always simple, don't hestitate to ask for help (beware of 'em gotchas 😓).
We appreciate your effort and would like the process to be productive and enjoyable.
A strong community means a strong and better product for everyone.
-->


<!--
📣 IMPORTANT NOTICE - PR LOCKDOWN 🔒 04/2022
We are excited to announce that fabric is migrating to modern typescript/javascript 🤩.
This means we will ⛔ not be accepting any PRs out of scope with the migration.
We understand this might be annoying but wasted work is ever more so.
The migration will be extreme on the source code so PRs from before will probably become stale to the point of death after the migration.
It hurts us the throw away good work, effort and time put into fabric so please stay patient.
You are welcome to join the migration effort 🔨
https://github.com/fabricjs/fabric.js/issues/7596
If you remain strong minded about PRing and the fix is small you can submit a PR to the 5.x branch
During the migration we will port these changes to master
-->



## Motivation
<!-- Why you are proposing -->
<!-- You can use the @closes notation to mark issues that will be resolved by this PR -->

## Description
<!-- What you are proposing -->

## Changes
<!-- before the fix vs. after -->

## Gist
<!-- Technical stuff if necessary -->

## In Action
<!-- Show case your accomplishment -->
<!-- Upload screenshots, screencasts and live examples showing your fix in contrast to the current state -->
2 changes: 1 addition & 1 deletion .github/workflows/node-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build:fast
- run: npm run test
- run: npm run test -- --suite unit
2 changes: 1 addition & 1 deletion .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
release:
branches:
- master
- v3.x
- 5.x
types: [published]

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/visual-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build:fast
- run: npm run test:visual
- run: npm run test -- --suite visual
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ before_commit
.idea/
/dist/fabric.require.js
/dist/fabric.min.js.gz
/scripts/cli_cache.json
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Changelog

# Changelog

## [next]

- MAJOR feat(fabric.Point): divide, scalarDivide, scalarDivideEquals [`#7716`](https://github.com/fabricjs/fabric.js/pull/7716)
- MAJOR feat(): Reuse fabric.Point logic for scaling and naming consistency [`#7710`](https://github.com/fabricjs/fabric.js/pull/7710)
- feat(Canvas#getCenter): migrate to `getCenterPoint` [`#7699`](https://github.com/fabricjs/fabric.js/pull/7699)
- MAJOR feat(fabric) remove callbacks in for Promise support [`#7657`](https://github.com/fabricjs/fabric.js/pull/7657)
- chore(): BREAKING Cleanup fabric.Point for v6 (#7709) [`7e563c7`](https://github.com/fabricjs/fabric.js/commit/7e563c72164070aafb03043643e85d06d0dee32c)

## [5.2.1]

- fix(): add `eraser` to Object state/cache props [`#7720`](https://github.com/fabricjs/fabric.js/pull/7720)

## [5.2.0]

- feat(fabric.Object): isType accepts multiple `type` [`#7715`](https://github.com/fabricjs/fabric.js/pull/7715)
- chore(): Replace deprecated String.prototype.substr() with Array.prototype.slice() [`#7696`](https://github.com/fabricjs/fabric.js/pull/7696)
- chore(): use Array.isArray instead of ie6+ workarounds [`#7718`](https://github.com/fabricjs/fabric.js/pull/7718)
- MINOR: feat(fabric.Canvas): add `getTopContext` method to expose the internal contextTop [`#7697`](https://github.com/fabricjs/fabric.js/pull/7697)
- fix(fabric.Object) Add cacheContext checks before trying to render on cache [`#7694`](https://github.com/fabricjs/fabric.js/pull/7694)
- tests(): node test suite enhancement [`#7691`](https://github.com/fabricjs/fabric.js/pull/7691)
- feat(Canvas#getCenter): migrate to `getCenterPoint` [`#7699`](https://github.com/fabricjs/fabric.js/pull/7699)
- updated package.json [`803ce95`](https://github.com/fabricjs/fabric.js/commit/803ce95878150fba9e4195804bccae9bcfe45c6d)
- tests(fabric.animation): fix test reliability [`4be0fb9`](https://github.com/fabricjs/fabric.js/commit/4be0fb9903e15db294b89030feb645e5da766740)

## [5.1.0]

- build(deps): bump node-fetch from 2.6.6 to 2.6.7 [`#7684`](https://github.com/fabricjs/fabric.js/pull/7684)
Expand Down
61 changes: 45 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# Contributing to Fabric

1. [Questions?!?](#questions)
2. [Issue tracker](#issue-tracker)
3. [Issue tracker guidelines](#issue-tracker-guidelines)
4. [Pull requests](#pull-request)
5. [Pull request guidelines](#pull-request-guidelines)

## Questions?!?

To get your questions answered, please ask/search on [Fabric's google group], [StackOverflow] or on Fabric's IRC channel (irc://irc.freenode.net/#fabric.js).
Expand All @@ -24,21 +18,28 @@ If you are sure that it's a bug in Fabric.js or a suggestion, open a new [issue]

### Issue tracker guidelines

- **Search:** Before opening a new issue please [search](https://github.com/fabricjs/fabric.js/search?q=&ref=cmdform&type=Issues) Fabric's existing issues.
If you think you found a bug in Fabric file an [issue](https://github.com/fabricjs/fabric.js/issues).

- **Gotchas**: Make sure you didn't fall into a known [fabric-gotcha](http://fabricjs.com/fabric-gotchas)

- **Search:** Before opening a new issue please take the time to [search](https://github.com/fabricjs/fabric.js/search?q=&ref=cmdform&type=Issues) Fabric's existing issues. This is vital to prevent spamming and to keep the community in a good state.

- **Title:** Choose an informative title.

- **Description:** Use the questions above to describe the issue. Add logs, screenshots or videos if that makes sense.

- **Test case:** Please post code to replicate the bug - best on [jsfiddle](http://jsfiddle.net). Ideally a failing test would be
perfect, but even a simple script demonstrating the error would suffice. You could use [this jsfiddle template](http://jsfiddle.net/fabricjs/Da7SP/) as a
starting point.
- **Test case:** Make sure you create a minimal and immediate test case, demonstrating the bug, with relevant explanations. It should be extremely **easy** and **fast** for someone to understand your bug and reproduce it. Bug templates can be found within a [bug report](https://github.com/fabricjs/fabric.js/issues/new?assignees=&labels=&template=bug_report.md)

- **Fabric.js version:** Make sure to specify which version of Fabric.js you are using. The version can be found in [fabric.js file](https://github.com/fabricjs/fabric.js/blob/master/dist/fabric.js#L5) or just by executing `fabric.version` in the browser console.
- **Fabric.js version:** Make sure to specify which version of Fabric.js you are using. The version can be found in [fabric.js file](https://github.com/fabricjs/fabric.js/blob/master/dist/fabric.js#L5) or just by executing `fabric.version` in the browser console. It is advised you upgrade to the latest version before proceeding.

**Without these requirements issues shall be closed.**

If you're unsure about something that is not a bug, it's best to start a [discussion](https://github.com/fabricjs/fabric.js/discussions) or create a post on [Fabric's google group](groups.google.com/forum/?fromgroups#!forum/fabricjs) where someone might clarify some of the things.

## Pull requests

We are very grateful for your pull requests! This is your chance to improve Fabric for everyone else.
Before you begin read this through and take a look at [fabric-gotchas](http://fabricjs.com/fabric-gotchas)

### Online one-click setup for making PRs

Expand All @@ -48,18 +49,46 @@ Contribute to fabricjs using a fully featured online development environment tha

### Setting up a local environment

Coming Soon!
1. Clone your fork of `fabric.js` to your machine
1. Install dependencies: `npm i`

You can decide how you prefer to work:

### Working on fabricjs.com
#### `fabricjs.com`
You can start the dev server that runs fabric's website and test live changes.
After setting up `fabricjs.com` on your machine run `npm start` from the `fabric.js` folder.
This will start the dev server and watch for changes in both repositories.
While working, you might need to refresh the page for changes to take place.
See [Working on fabricjs.com](#working-on-fabricjscom).
To customize the dev server take a look at [`./scripts`](./scripts).

#### symlinking
You can symlink `fabric.js` and test your changes in a separate project.
1. From `fabric.js` folder run `npm link` **OR** `yarn link`.
1. From your project's folder run `npm link fabric` **OR** `yarn link fabric`.

See [npm link](https://docs.npmjs.com/cli/v8/commands/npm-link) **OR** [yarn link](https://yarnpkg.com/cli/link).\
Don't forget to unlink the package once you're done.

### Working on `fabricjs.com`

To develop fabric's site you need to clone [`fabricjs.com`](https://github.com/fabricjs/fabricjs.com) in the same parent folder of [`fabric.js`](https://github.com/fabricjs/fabric.js), so that `fabric.js` and `fabricjs.com` are siblings.
To start the dev server run `npm start` inside the `fabricjs.com` directory (after installing dependecies).
To start the dev server run `npm start:dev` inside the `fabricjs.com` directory (after installing dependecies).
If you are working on windows, check out [`jekyll` docs](https://jekyllrb.com/docs/installation/) for futher instructions.

**Adding a DEMO**:
Take a look at an existing [demo file](https://github.com/fabricjs/fabricjs.com/blob/gh-pages/posts/demos/_posts/2020-2-15-custom-control-render.md).
Create a new file in the same directory (`posts/demos/_posts`) and you're good to go.

### Tests
Fabric has 2 test suites:
- `unit` testing logic and state
- `visual` testing visual outcome against image refs

#### Running Tests
- **Node.js**: run `npm test -- -a -d` to run **a**ll tests in **d**ebug mode (pass `--help` to see more options).
- **Browser**: start `fabricjs.com` (`npm start`) and navigate to the `tests` tab where you will find the test interface.

### Pull request guidelines

Here are a few notes you should take into account:
Expand All @@ -68,7 +97,7 @@ Here are a few notes you should take into account:

- **Distribution files:** Do your changes only in the [source files](https://github.com/fabricjs/fabric.js/tree/master/src). Don't include the [distribution files](https://github.com/fabricjs/fabric.js/tree/master/dist) in your commit.

- **Add tests**: Tests are always a great addition - invest a little time and expand the [unit tests suite](https://github.com/fabricjs/fabric.js/tree/master/test/unit). More informations about [QUnit](http://qunitjs.com/) tests can be found in the [wiki](https://github.com/fabricjs/fabric.js/wiki/How-to-contribute-to-Fabric#testing-fabric).
- **Add tests**: Tests are vital - invest time to extend the [tests suites](https://github.com/fabricjs/fabric.js/tree/master/test). More information about [QUnit](http://qunitjs.com/) tests can be found in the [wiki](https://github.com/fabricjs/fabric.js/wiki/How-to-contribute-to-Fabric#testing-fabric).

- **Add documentation:** Fabric uses [JSDoc 3] for documentation. The generated documentation can be found at [fabricjs.com](http://fabricjs.com/docs).

Expand All @@ -89,4 +118,4 @@ Here are a few notes you should take into account:
[fabricjs.com]: http://fabricjs.com/demos
[fabricjs.com/docs]: http://fabricjs.com/docs
[JSDoc 3]: http://usejsdoc.org/
[issue]: https://github.com/kangax/fabric.js/issues
[issue]: https://github.com/fabric/fabric.js/issues
1 change: 1 addition & 0 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ var filesToInclude = [
'src/shapes/object.class.js',
'src/mixins/object_origin.mixin.js',
'src/mixins/object_geometry.mixin.js',
'src/mixins/object_ancestry.mixin.js',
'src/mixins/object_stacking.mixin.js',
'src/mixins/object.svg_export.js',
'src/mixins/stateful.mixin.js',
Expand Down
4 changes: 2 additions & 2 deletions lib/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ var eventManager = function(target, type, listener, configure, trigger, fromOver
}
return createBatchCommands(events);
} else if (type.indexOf("on") === 0) { // to support things like "onclick" instead of "click"
type = type.substr(2);
type = type.slice(2);
}

// Ensure listener is a function.
Expand Down Expand Up @@ -1368,7 +1368,7 @@ root.gesture = function(conf) {
var dx = touch.move.x - self.x;
var dy = touch.move.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// If touch start.distance from centroid is 0, scale should not be updated.
// If touch start.distance from centroid is 0, scale should not be updated.
// This prevents dividing by 0 in cases where start.distance is oddly 0.
if (start.distance !== 0) {
scale += distance / start.distance;
Expand Down
6 changes: 3 additions & 3 deletions old-travis-reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- stage: Visual Tests
env: LAUNCHER=Node
node_js: "12"
script: npm run build:fast && npm run test:visual
script: npm run build:fast && npm run test -- --suite visual
- stage: Visual Tests
env: LAUNCHER=Chrome
script: npm run build:fast && testem ci --port 8080 -f testem-visual.json -l $LAUNCHER
Expand All @@ -84,13 +84,13 @@ jobs:
# - stage: Extra OS
# env: CANFAIL=TRUE
# node_js: "10"
# script: npm run build:fast && npm run test:visual
# script: npm run build:fast && npm run test -- --suite visual
# before_install: brew upgrade giflib && brew install pkg-config cairo pango libpng jpeg librsvg
# os: osx
# - stage: Extra OS
# env: CANFAIL=TRUE
# node_js: "10"
# script: npm run build:fast && npm run test:visual
# script: npm run build:fast && npm run test -- --suite visual
# os: windows
script: npm run build:fast && npm run test

Expand Down
Loading

0 comments on commit d8eb923

Please sign in to comment.