Skip to content
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
2 changes: 1 addition & 1 deletion .codesandbox/templates/vanilla/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fabric from 'fabric';
import './styles.css';
import { testCase } from './testcases/clipPathSelection';
import { testCase } from './testcases/guidelines';

const el = document.getElementById('canvas');
const canvas = (window.canvas = new fabric.Canvas(el, {
Expand Down
46 changes: 39 additions & 7 deletions .codesandbox/templates/vanilla/src/testcases/guidelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,45 @@ import * as fabric from 'fabric';
import { initAligningGuidelines } from 'fabric/extensions';

export async function testCase(canvas: fabric.Canvas) {
initAligningGuidelines(canvas, {
width: 2,
margin: 60,
});
initAligningGuidelines(
canvas,
{
width: 2,
margin: 60,
},
// Filter predicate to exclude red filled objects from snapping
(potentialSnappingTarget: fabric.FabricObject) =>
potentialSnappingTarget.fill === 'red',
);

const rect = new fabric.Rect({ width: 50, height: 50, fill: 'blue' });
const rect2 = new fabric.Rect({ width: 50, height: 50, fill: 'blue' });
const rect = new fabric.Rect({
width: 50,
height: 50,
fill: 'blue',
top: 10,
left: 10,
});
const rect2 = new fabric.Rect({
width: 50,
height: 50,
top: 100,
left: 100,
fill: 'blue',
});
const rect3 = new fabric.Rect({
width: 50,
height: 50,
top: 175,
left: 75,
fill: 'red',
});
const rect4 = new fabric.Rect({
width: 50,
height: 50,
top: 75,
left: 350,
fill: 'red',
});

canvas.add(rect, rect2);
canvas.add(rect, rect2, rect3, rect4);
}
2 changes: 1 addition & 1 deletion dist-extensions/fabric-extensions.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist-extensions/fabric-extensions.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.min.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.min.mjs.map

Large diffs are not rendered by default.

Loading