fastdom: toying around with what works and what doesn't
This commit is contained in:
parent
3e06e52948
commit
e7693d2277
6 changed files with 46 additions and 39 deletions
|
|
@ -2,6 +2,7 @@ var widgetManager = require('../managers/widgets'),
|
|||
resize = require('../events/resize'),
|
||||
stateManager = require('../managers/state'),
|
||||
parser = require('../parser'),
|
||||
fastdom = require('fastdom'),
|
||||
Panel, Matrix,
|
||||
editor,
|
||||
scrollState = {}
|
||||
|
|
@ -113,8 +114,9 @@ function updateWidget(widget, options={}) {
|
|||
index: index
|
||||
})
|
||||
|
||||
|
||||
newWidget.container.parentNode.replaceChild(newWidget.container, widget.container)
|
||||
// fastdom.mutate(()=>{
|
||||
newWidget.container.parentNode.replaceChild(newWidget.container, widget.container)
|
||||
// })
|
||||
|
||||
if (newWidget.getProp('type') === 'tab') newWidget.parent.trigger('tab-created', {widget: widget})
|
||||
|
||||
|
|
|
|||
|
|
@ -26,16 +26,14 @@ function checkResizes(context, force){
|
|||
cachedStyles.push(style)
|
||||
}
|
||||
}
|
||||
fastdom.mutate(()=>{
|
||||
for (let i = resizedElems.length - 1; i >= 0; i--) {
|
||||
resizedElems[i]._resize_widget.trigger('resize', {
|
||||
width: resizedElems[i].resizedataw,
|
||||
height: resizedElems[i].resizedatah,
|
||||
style:cachedStyles[i],
|
||||
stopPropagation: true
|
||||
})
|
||||
}
|
||||
})
|
||||
for (let i = resizedElems.length - 1; i >= 0; i--) {
|
||||
resizedElems[i]._resize_widget.trigger('resize', {
|
||||
width: resizedElems[i].resizedataw,
|
||||
height: resizedElems[i].resizedatah,
|
||||
style:cachedStyles[i],
|
||||
stopPropagation: true
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,33 +157,33 @@ class UiInspectorField extends UiWidget {
|
|||
colorData = this.widget.constructor.cssVariables.find(x=>x.js === this.name),
|
||||
val = 'transparent'
|
||||
|
||||
fastdom.measure(()=>{
|
||||
// fastdom.measure(()=>{
|
||||
try {
|
||||
val = chroma(style.getPropertyValue(colorData.css).trim()).hex('rgba')
|
||||
} catch(e) {}
|
||||
fastdom.mutate(()=>{
|
||||
// fastdom.mutate(()=>{
|
||||
this.container.appendChild(html`
|
||||
<osc-inspector-color type="text" name="${this.name}" value="${val}" style="--color-picker-value: ${val}"></osc-inspector-color>
|
||||
`)
|
||||
})
|
||||
// })
|
||||
|
||||
})
|
||||
// })
|
||||
|
||||
} else if (stringValue === 'auto' && this.widget.constructor.cssVariables.some(x=>x.js === this.name)) {
|
||||
|
||||
fastdom.measure(()=>{
|
||||
// fastdom.measure(()=>{
|
||||
let style = window.getComputedStyle(this.widget.container),
|
||||
data = this.widget.constructor.cssVariables.find(x=>x.js === this.name),
|
||||
val = style.getPropertyValue(data.css).trim()
|
||||
|
||||
if (data.toJs) val = data.toJs(val)
|
||||
fastdom.mutate(()=>{
|
||||
// fastdom.mutate(()=>{
|
||||
this.container.appendChild(html`
|
||||
<div class="computed-value">${val}</div>
|
||||
`)
|
||||
})
|
||||
// })
|
||||
|
||||
})
|
||||
// })
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,12 +89,18 @@ class Canvas extends Widget {
|
|||
this.container.style.setProperty('--widget-height', this.height + 'rem')
|
||||
this.container.style.setProperty('--widget-width', this.width + 'rem')
|
||||
|
||||
this.ctx.font = this.fontWeight + ' ' + this.fontSize + 'px ' + this.fontFamily
|
||||
this.ctx.textBaseline = 'middle'
|
||||
this.ctx.textAlign = this.textAlign
|
||||
|
||||
if (!this.hasSize) {
|
||||
this.hasSize = true
|
||||
this.setVisibility()
|
||||
this.batchDraw()
|
||||
} else {
|
||||
this.draw()
|
||||
}
|
||||
|
||||
this.batchDraw()
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -137,11 +143,6 @@ class Canvas extends Widget {
|
|||
this.fontSize = parseFloat(style.getPropertyValue('font-size').trim())
|
||||
this.fontWeight = parseFloat(style.getPropertyValue('font-weight').trim())
|
||||
|
||||
this.ctx.font = this.fontWeight + ' ' + this.fontSize + 'px ' + this.fontFamily
|
||||
this.ctx.textBaseline = 'middle'
|
||||
this.ctx.textAlign = this.textAlign
|
||||
|
||||
|
||||
}
|
||||
|
||||
clear() {
|
||||
|
|
|
|||
|
|
@ -177,13 +177,15 @@ module.exports = class MultiXy extends Pad {
|
|||
|
||||
super.resizeHandle(event)
|
||||
|
||||
for (var k in this.pads) {
|
||||
this.pads[k].width = this.width
|
||||
this.pads[k].height = this.height
|
||||
this.pads[k].padPadding = this.padPadding
|
||||
}
|
||||
fastdom.measure(()=>{
|
||||
for (var k in this.pads) {
|
||||
this.pads[k].width = this.width
|
||||
this.pads[k].height = this.height
|
||||
this.pads[k].padPadding = this.padPadding
|
||||
}
|
||||
this.updateHandlesPosition()
|
||||
})
|
||||
|
||||
this.updateHandlesPosition()
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
var Pad = require('./pad'),
|
||||
Fader = require('../sliders/fader'),
|
||||
doubletab = require('../mixins/double_tap'),
|
||||
touchstate = require('../mixins/touch_state')
|
||||
touchstate = require('../mixins/touch_state'),
|
||||
fastdom = require('fastdom')
|
||||
|
||||
var faderDefaults = Fader.defaults()._props()
|
||||
|
||||
|
|
@ -156,12 +157,15 @@ module.exports = class Xy extends Pad {
|
|||
|
||||
super.resizeHandle(event)
|
||||
|
||||
for (var k in this.faders) {
|
||||
this.faders[k].width = this.width
|
||||
this.faders[k].height = this.height
|
||||
this.faders[k].gaugePadding = this.padPadding
|
||||
|
||||
}
|
||||
fastdom.measure(()=>{
|
||||
fastdom.mutate(()=>{
|
||||
for (var k in this.faders) {
|
||||
this.faders[k].width = this.width
|
||||
this.faders[k].height = this.height
|
||||
this.faders[k].gaugePadding = this.padPadding
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue