ddd
This commit is contained in:
parent
0a343ecbc5
commit
c3a6f5ff37
80 changed files with 2512 additions and 1625 deletions
30
client/ui/cursor.js
Normal file
30
client/ui/cursor.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
(function(root,factory){
|
||||
const api=factory();
|
||||
if(typeof module==='object'&&module.exports)module.exports=api;
|
||||
root.BendCursorModel=api;
|
||||
})(typeof globalThis!=='undefined'?globalThis:this,function(){
|
||||
'use strict';
|
||||
|
||||
function createCursorModel(items=[]){
|
||||
const byStyle=new Map();
|
||||
for(const item of items)if(item?.cursorStyle)byStyle.set(item.cursorStyle,Object.freeze({...item}));
|
||||
const item=style=>byStyle.get(String(style||''))||null;
|
||||
const presentation=style=>{
|
||||
const selected=item(style);
|
||||
if(!selected)return Object.freeze({style:'default',mode:'default',asset:null,glyph:'',flag:false,hotspot:Object.freeze([0,0]),pickup:Object.freeze({kind:'default'})});
|
||||
const flag=Boolean(selected.flagAsset),asset=selected.flagAsset||null,glyph=flag?'':selected.cursorEmoji||'';
|
||||
return Object.freeze({
|
||||
style:selected.cursorStyle,
|
||||
mode:'dom',
|
||||
asset,
|
||||
glyph,
|
||||
flag,
|
||||
hotspot:Object.freeze([.5,.5]),
|
||||
pickup:Object.freeze({kind:flag?'flag':'glyph',asset,glyph})
|
||||
});
|
||||
};
|
||||
return Object.freeze({item,presentation,styles:()=>Object.freeze([...byStyle.keys()])});
|
||||
}
|
||||
|
||||
return Object.freeze({createCursorModel});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue