Working on stacked buttons.
This commit is contained in:
+16
-57
@@ -48,10 +48,7 @@ export class CardPluginBase {
|
||||
}
|
||||
|
||||
_getVerificationFunctions(context) {
|
||||
return [
|
||||
this._verifyContext.bind(this, context),
|
||||
this._verifyRequirements.bind(this, context)
|
||||
]
|
||||
return [this._verifyContext.bind(this, context), this._verifyRequirements.bind(this, context)]
|
||||
}
|
||||
|
||||
_verifyContext(context) {
|
||||
@@ -139,11 +136,7 @@ CardPlugin.EnlargeableThumbnail = class EnlargeableThumbnail extends CardPluginB
|
||||
constructor(
|
||||
wrapperSelector,
|
||||
overlaySelector = null,
|
||||
{
|
||||
zoomAnimationDuration = 0.4,
|
||||
fadeAnimationDuration = 0.4,
|
||||
interactionType = 'tap'
|
||||
} = {}
|
||||
{ zoomAnimationDuration = 0.4, fadeAnimationDuration = 0.4, interactionType = 'tap' } = {}
|
||||
) {
|
||||
super()
|
||||
this.wrapperSelector = wrapperSelector
|
||||
@@ -160,14 +153,7 @@ CardPlugin.EnlargeableThumbnail = class EnlargeableThumbnail extends CardPluginB
|
||||
|
||||
_getVerificationFunctions(context) {
|
||||
let arr = super._getVerificationFunctions(context)
|
||||
let funcs = [
|
||||
this._verifyElementsExist.bind(
|
||||
this,
|
||||
context,
|
||||
this.wrapperSelector,
|
||||
this.overlaySelector
|
||||
)
|
||||
]
|
||||
let funcs = [this._verifyElementsExist.bind(this, context, this.wrapperSelector, this.overlaySelector)]
|
||||
return arr.concat(funcs)
|
||||
}
|
||||
|
||||
@@ -252,9 +238,7 @@ CardPlugin.EnlargeableThumbnail = class EnlargeableThumbnail extends CardPluginB
|
||||
* The minor side should not exceed the height of the context window.
|
||||
*/
|
||||
const maxMinorSize =
|
||||
context.offsetHeight -
|
||||
2 * parseInt(headerStlye.paddingTop) -
|
||||
2 * parseInt(headerStlye.marginTop)
|
||||
context.offsetHeight - 2 * parseInt(headerStlye.paddingTop) - 2 * parseInt(headerStlye.marginTop)
|
||||
|
||||
const max = {
|
||||
width: context.offsetWidth * maxFillRatio,
|
||||
@@ -284,10 +268,7 @@ CardPlugin.EnlargeableThumbnail = class EnlargeableThumbnail extends CardPluginB
|
||||
// const minorImageSize = getImageSize(minorSide)
|
||||
|
||||
let ratio = getImageSize(minorSide) / getImageSize(majorSide)
|
||||
let size =
|
||||
majorImageSize > max[majorSide.name]
|
||||
? max[majorSide.name]
|
||||
: majorImageSize
|
||||
let size = majorImageSize > max[majorSide.name] ? max[majorSide.name] : majorImageSize
|
||||
|
||||
if (size * ratio > maxMinorSize) {
|
||||
size = maxMinorSize / ratio
|
||||
@@ -298,10 +279,7 @@ CardPlugin.EnlargeableThumbnail = class EnlargeableThumbnail extends CardPluginB
|
||||
height: 0
|
||||
}
|
||||
|
||||
let position = Points.fromPageToNode(
|
||||
context,
|
||||
Points.fromNodeToPage(source, { x: 0, y: 0 })
|
||||
)
|
||||
let position = Points.fromPageToNode(context, Points.fromNodeToPage(source, { x: 0, y: 0 }))
|
||||
|
||||
let targetOffset = {
|
||||
x: 0,
|
||||
@@ -312,13 +290,9 @@ CardPlugin.EnlargeableThumbnail = class EnlargeableThumbnail extends CardPluginB
|
||||
targetDimensions[minorSide.name] = size * ratio
|
||||
|
||||
targetOffset[majorSide.axis] =
|
||||
(context['offset' + capitalize(majorSide.name)] -
|
||||
targetDimensions[majorSide.name]) /
|
||||
2
|
||||
(context['offset' + capitalize(majorSide.name)] - targetDimensions[majorSide.name]) / 2
|
||||
targetOffset[minorSide.axis] =
|
||||
(context['offset' + capitalize(minorSide.name)] -
|
||||
targetDimensions[minorSide.name]) /
|
||||
2
|
||||
(context['offset' + capitalize(minorSide.name)] - targetDimensions[minorSide.name]) / 2
|
||||
|
||||
overlay.appendChild(imageWrapper)
|
||||
|
||||
@@ -358,18 +332,14 @@ CardPlugin.EnlargeableThumbnail = class EnlargeableThumbnail extends CardPluginB
|
||||
}
|
||||
|
||||
getBorderHeight(style) {
|
||||
const borderWidth =
|
||||
parseInt(style.borderTopWidth) + parseInt(style.borderBottomWidth)
|
||||
const padding =
|
||||
parseInt(style.paddingTop) + parseInt(style.paddingBottom)
|
||||
const borderWidth = parseInt(style.borderTopWidth) + parseInt(style.borderBottomWidth)
|
||||
const padding = parseInt(style.paddingTop) + parseInt(style.paddingBottom)
|
||||
return parseInt(style.width) + borderWidth + padding
|
||||
}
|
||||
|
||||
getBorderWidth(style) {
|
||||
const borderWidth =
|
||||
parseInt(style.borderLeftWidth) + parseInt(style.borderRightWidth)
|
||||
const padding =
|
||||
parseInt(style.paddingLeft) + parseInt(style.paddingRight)
|
||||
const borderWidth = parseInt(style.borderLeftWidth) + parseInt(style.borderRightWidth)
|
||||
const padding = parseInt(style.paddingLeft) + parseInt(style.paddingRight)
|
||||
return parseInt(style.width) + borderWidth + padding
|
||||
}
|
||||
|
||||
@@ -404,16 +374,12 @@ CardPlugin.Ui = class UiPlugin extends CardPluginBase {
|
||||
_doesParentExist(context, parent) {
|
||||
if (parent == null) return true
|
||||
let valid = context.querySelector(parent) != null
|
||||
if (!valid)
|
||||
console.error('Could not find parent on context.', context, parent)
|
||||
if (!valid) console.error('Could not find parent on context.', context, parent)
|
||||
return valid
|
||||
}
|
||||
|
||||
append(context) {
|
||||
parent =
|
||||
this.parent == null
|
||||
? context
|
||||
: context.querySelector(this.parent).appendChild(container)
|
||||
parent = this.parent == null ? context : context.querySelector(this.parent).appendChild(container)
|
||||
let container = document.createElement('div')
|
||||
container.className = this.className
|
||||
parent.appendChild(container)
|
||||
@@ -513,15 +479,8 @@ CardPlugin.Speech = class SpeechPlugin extends CardPluginBase {
|
||||
|
||||
utterance.onboundary = () => {
|
||||
console.log('onboundary', node.innerText)
|
||||
if (
|
||||
this.currentText.substring(0, 5) !=
|
||||
node.innerText.substring(0, 5)
|
||||
) {
|
||||
console.log(
|
||||
'text for speech synth changed!',
|
||||
this.currentText,
|
||||
node.innerText
|
||||
)
|
||||
if (this.currentText.substring(0, 5) != node.innerText.substring(0, 5)) {
|
||||
console.log('text for speech synth changed!', this.currentText, node.innerText)
|
||||
this._stop()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user