canvas: expose touch events for extra elements added with the html propery

This commit is contained in:
jean-emmanuel 2021-12-22 11:46:09 +01:00
parent 6b76631003
commit 4ce9506e91
6 changed files with 27 additions and 12 deletions

View file

@ -89,7 +89,7 @@ class Widget extends EventEmitter {
'  b, i, strong, em, strike, code, hr, br, div,',
'  table, thead, img, caption, tbody, tr, th, td, pre',
'Allowed attributes:',
'  <*>: class, style, title',
'  <*>: class, style, title, name',
'  <img>: src, width, height',
]},
css: {type: 'string', value: '', help: [
@ -1192,7 +1192,7 @@ class Widget extends EventEmitter {
Widget.sanitizeHtmlOptions = {
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'h1', 'h2']).filter(x=>x!=='iframe'),
allowedAttributes: {
'*': [ 'title', 'class', 'style'],
'*': [ 'title', 'class', 'style', 'name'],
'img': [ 'src' , 'title', 'class', 'style', 'width', 'height'],
'a': ['href', 'target']
},

View file

@ -75,6 +75,8 @@ class CanvasWidget extends Canvas {
var event = {...e}
delete event.firstTarget
event.targetName = event.target.getAttribute('name')
event.targetTagName = event.target.tagName
var w = widgetManager.getWidgetByElement(event.target)
if (w) event.target = w === this ? 'this' : w.getProp('id')
else event.target = null
@ -92,15 +94,15 @@ class CanvasWidget extends Canvas {
this.on('draginit',(e)=>{
touchCb(e, 'start')
}, {element: this.widget, multitouch: true})
}, {element: this.container, multitouch: true})
this.on('drag',(e)=>{
touchCb(e, 'move')
}, {element: this.widget, multitouch: true})
}, {element: this.container, multitouch: true})
this.on('dragend',(e)=>{
touchCb(e, 'stop')
}, {element: this.widget, multitouch: true})
}, {element: this.container, multitouch: true})
if (this.getProp('continuous')) {
var freq = parseInt(this.getProp('continuous')) || 30
@ -131,6 +133,8 @@ class CanvasWidget extends Canvas {
draw() {
if (!this.getProp('draw')) return
if (this.getProp('autoClear')) {
this.clear()
this.ctx.beginPath()
@ -143,6 +147,7 @@ class CanvasWidget extends Canvas {
height: this.height,
cssVars: this.cssVars
}, {sync: false, send: false})
this.batchDraw()
}

View file

@ -134,7 +134,10 @@
--alpha-fill-on: 0.75;
--alpha-fill: var(--alpha-fill-off);
--widget-padding: 0rem;
.html {
pointer-events: auto;
}
inner {
position: relative;
flex: 1;