当前位置:网站首页>Fabric. JS activation input box
Fabric. JS activation input box
2022-07-02 05:18:00 【Director of Moral Education Department】
Brief introduction
give the thumbs-up + Focus on + Collection = Learned to
<br>
stay HTML
in ,input
The input box has 2 Methods of auto focusing , The simplest is in input
Add on label autofocus
attribute .
The way to click again is to use JS
Get input box element , Call again focus
Event check input box .
stay Fabric.js
in ,IText
Components provide a similar approach .
<br>
<br>
Practice
Fabric.js
Of IText
Is an editable text box , You can enter text while the project is running , The function is actually the same as HTML
Of input
almost , Can let the user input .
<br>
By default
stay Fabric.js
in , If you're creating IText
No text was added to the , It's hard to see where your input box is on the canvas with the naked eye .
<canvas id="canvasBox" width="600" height="600" style="border: 1px solid #ccc;"></canvas><!-- introduce Fabric.js --><script src="https://cdn.bootcdn.net/ajax/libs/fabric.js/521/fabric.js"></script><script> const canvas = new fabric.Canvas('canvasBox') const iText = new fabric.IText('', { left: 100, // The distance from the input box to the left of the canvas top: 100, // The distance from the input box to the top of the canvas padding: 7 // Set the inside margin of the input box }) canvas.add(iText) // Add an input box to the canvas </script>
The canvas and input box are created , But it's hard to find the input box with the naked eye .
<br>
Activate the input box
To solve these problems , Input box can be activated .
// Omitted code iText.enterEditing()
use enterEditing()
Method to activate the input field . At this point, you can see that the position of the cursor is flashing .
<br>
Further
Use enterEditing()
The rear input box is activated , You can also see the cursor flashing .
But is that the end of it ?
We can go further , coordination Fabric Canvas
Of setActiveObject()
Method , Activate the selected object .
In this way, the effect of selecting the input box will be more obvious .
// Omitted code canvas.add(iText).setActiveObject(iText)iText.enterEditing()
It can be seen from the above figure that , add setActiveObject()
after , The effect is more obvious .
<br>
<br>
summary
Fabric.js
It's not hard , It is better than using native Canvas
It's a lot easier .
Use Fabric.js
The most important thing is to read more documents , Then put multiple api
Use in combination , Can create a variety of effects ~
<br>
<br>
Code warehouse
<br>
<br>
Recommended reading
《Fabric.js Output reduced JSON》
《Fabric.js IText Set the specified character color and background color 》
《console.log You can also use illustrations !!!》
《 The front-end needs free online api Interface 》
give the thumbs-up + Focus on + Collection = Learned to
边栏推荐
- Black Horse Notes - - set Series Collection
- Splice characters in {{}}
- Global and Chinese market of pressure gauges 2022-2028: Research Report on technology, participants, trends, market size and share
- Pyechats 1.19 generate a web version of Baidu map
- Express logistics quick query method, set the unsigned doc No. to refresh and query automatically
- el-cascader回显只选中不显示的问题
- Fabric.js 背景不受视口变换影响
- Johnson–Lindenstrauss Lemma(2)
- Nodejs (02) - built in module
- 4. Flask cooperates with a tag to link internal routes
猜你喜欢
2022阿里巴巴全球数学竞赛 第4题 虎虎生威(盲盒问题、集卡问题)解决思路
运维工作的“本手、妙手、俗手”
Preparation for writing SAP ui5 applications using typescript
The El cascader echo only selects the questions that are not displayed
MySQL foundation --- query (learn MySQL foundation in 1 day)
Collectors.groupingBy 排序
Fabric.js IText 上标和下标
Line by line explanation of yolox source code of anchor free series network (7) -- obj in head_ loss、Cls_ Loss and reg_ Calculation and reverse transmission of loss I
Gee series: unit 6 building various remote sensing indexes in Google Earth engine
Mathematical problems (number theory) trial division to judge prime numbers, decompose prime factors, and screen prime numbers
随机推荐
Fabric.js 3个api设置画布宽高
Gee series: Unit 5 remote sensing image preprocessing [GEE grid preprocessing]
There are duplicate elements in leetcode. Go implementation
Database batch insert data
go实现leetcode旋转数组
Fabric.js 圆形笔刷
Global and Chinese market of commercial fish tanks 2022-2028: Research Report on technology, participants, trends, market size and share
A new attribute value must be added to the entity entity class in the code, but there is no corresponding column in the database table
Fabric.js IText 上标和下标
Dark horse notes -- map set system
Fabric.js 渐变
Fabric.js IText设置指定文字的颜色和背景色
数据库批量插入数据
运维工作的“本手、妙手、俗手”
Using Kube bench and Kube hunter to evaluate the risk of kubernetes cluster
Exercise notes 13 (effective letter ectopic words)
【pyinstaller】_ get_ sysconfigdata_ name() missing 1 required positional argument: ‘check_ exists‘
el-cascader回显只选中不显示的问题
National all Chinese Automatic Test Software apifox
No logic is executed after the El form is validated successfully