当前位置:网站首页>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
边栏推荐
- Latest: the list of universities and disciplines for the second round of "double first-class" construction was announced
- ubuntu20.04安装mysql8
- Dark horse notes -- Set Series Collection
- Video multiple effects production, fade in effect and border background are added at the same time
- [quick view opencv] familiar with CV matrix operation with image splicing examples (3)
- Leetcode basic programming: array
- Global and Chinese markets for marine selective catalytic reduction systems 2022-2028: Research Report on technology, participants, trends, market size and share
- [high speed bus] Introduction to jesd204b
- Gee data set: export the distribution and installed capacity of hydropower stations in the country to CSV table
- leetcode存在重复元素go实现
猜你喜欢
黑馬筆記---Set系列集合
Gee series: unit 8 time series analysis in Google Earth engine [time series]
视差特效的原理和实现方法
Operator details
Differential identities (help find mean, variance, and other moments)
Latest: the list of universities and disciplines for the second round of "double first-class" construction was announced
Cubemx DMA notes
Collectors.groupingBy 排序
Fabric.js 渐变
[opencv] image binarization
随机推荐
Mathematical knowledge -- understanding and examples of fast power
Express logistics quick query method, set the unsigned doc No. to refresh and query automatically
Global and Chinese market of travel data recorder (VDR) 2022-2028: Research Report on technology, participants, trends, market size and share
Video cover image setting, put cover images into multiple videos in the simplest way
Super detailed pycharm tutorial
Leetcode 18 problem [sum of four numbers] recursive solution
Gee series: unit 6 building various remote sensing indexes in Google Earth engine
php/js cookie共享跨域的问题
函数栈帧的创建和销毁
Fabric.js 背景不受视口变换影响
Leetcode18题 【四数之和】递归解法
el-cascader回显只选中不显示的问题
Global and Chinese markets of semiconductor laser therapeutics 2022-2028: Research Report on technology, participants, trends, market size and share
Collectors. Groupingby sort
Mysql基础---查询(1天学会mysql基础)
运维工作的“本手、妙手、俗手”
7.1 Résumé du concours de simulation
Fabric.js 圆形笔刷
Gee series: Unit 5 remote sensing image preprocessing [GEE grid preprocessing]
Here comes the chicken soup! Keep this quick guide for data analysts