Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: fix() Text on a path bounding box and cursor display #10209

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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/loadingSvgs';
import { testCase } from './testcases/simpleTextbox';

const el = document.getElementById('canvas');
const canvas = (window.canvas = new fabric.Canvas(el));
Expand Down
42 changes: 11 additions & 31 deletions .codesandbox/templates/vanilla/src/testcases/simpleTextbox.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,20 @@
import * as fabric from 'fabric';

export function testCase(canvas: fabric.Canvas) {
const textValue = 'fabric.js sandbox';
const text = new fabric.Textbox(textValue, {
originX: 'center',
splitByGrapheme: true,
const textValue = 'LOL';
const path = new fabric.Path(
'M0 200 v-200 h200 a100,100 90 0,1 0,200 a100,100 90 0,1 -200,0 z',
{
fill: '',
stroke: 'red',
},
);
const text = new fabric.IText(textValue, {
width: 200,
top: 20,
styles: fabric.util.stylesFromArray(
[
{
style: {
fontWeight: 'bold',
fontSize: 64,
},
start: 0,
end: 9,
},
],
textValue,
),
path,
objectCaching: false,
});
canvas.add(text);
canvas.centerObjectH(text);
function animate(toState) {
text.animate(
{ scaleX: Math.max(toState, 0.1) * 2 },
{
onChange: () => canvas.renderAll(),
onComplete: () => animate(!toState),
duration: 1000,
easing: toState
? fabric.util.ease.easeInOutQuad
: fabric.util.ease.easeInOutSine,
},
);
}
// animate(1);
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [next]

- WIP: fix() Text on a path bounding box and cursor display [#10209](https://github.com/fabricjs/fabric.js/pull/10209)
- feat(IText): expose getCursorRenderingData() function. [#10204](https://github.com/fabricjs/fabric.js/pull/10204)
- fix(Canvas): allowTouchScrolling interactions [#10078](https://github.com/fabricjs/fabric.js/pull/10078)
- update(IText): Add method enterEditingImpl/exitEditingImpl that executes the logic of enterEditing/exitEditing without events [#10187](https://github.com/fabricjs/fabric.js/issues/10187)
Expand Down
2 changes: 1 addition & 1 deletion dist-extensions/fabric.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export { FabricText,
*
*/
FabricText as Text, } from './src/shapes/Text/Text';
export type { ITextProps, SerializedITextProps, } from './src/shapes/IText/IText';
export type { ITextProps, SerializedITextProps, CursorRenderingData, CursorBoundaries, } from './src/shapes/IText/IText';
export { IText } from './src/shapes/IText/IText';
export type { GraphemeData, SerializedTextboxProps, TextboxProps, } from './src/shapes/Textbox';
export { Textbox } from './src/shapes/Textbox';
Expand Down
Loading