scrollbar: set a min size for the scrollthumb and continue implimentatiob
This commit is contained in:
parent
a95697045a
commit
5eae65a0aa
3 changed files with 20 additions and 8 deletions
|
|
@ -31,7 +31,7 @@ class Panel extends Container() {
|
|||
justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'},
|
||||
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns or a valid value for the css property "grid-template".'},
|
||||
contain: {type: 'boolean', value: true, help:'If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel.'},
|
||||
scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'},
|
||||
scroll: {type: 'boolean|string', value: true, choices: [true, false, 'hidden'], help: 'Set to `false` to disable scrollbars, set to `hidden` to hide scrollbars while allowing to scroll (may not work on old browsers).'},
|
||||
innerPadding: {type : 'boolean', value: true, help: 'Set to `false` to make the `padding` property apply only between children and not at the container\'s inner boundaries.'},
|
||||
tabsPosition: {type: 'string', value: 'top', choices: ['top', 'bottom', 'left', 'right', 'hidden'], help: 'Defines the position of the navigation bar if the panel contains tabs'},
|
||||
},
|
||||
|
|
@ -72,6 +72,7 @@ class Panel extends Container() {
|
|||
|
||||
this.container.classList.toggle('no-inner-padding', !this.getProp('innerPadding'))
|
||||
this.container.classList.toggle('no-scroll', !this.getProp('scroll'))
|
||||
this.container.classList.toggle('hidden-scroll', this.getProp('scroll') == 'hidden')
|
||||
this.container.classList.add('layout-' + this.getProp('layout'))
|
||||
this.container.classList.toggle('layout-contain', this.getProp('contain'))
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,15 @@ export default class Scrollbar extends StaticProperties(Fader, {
|
|||
}
|
||||
|
||||
}, {context: this})
|
||||
|
||||
var widgets = widgetManager.getWidgetById(this.getProp('widgetId'))
|
||||
for (var widget of widgets) {
|
||||
if (widget.getProp('scroll')) {
|
||||
this.unbindTarget()
|
||||
this.bindTarget(widget)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -110,7 +119,7 @@ export default class Scrollbar extends StaticProperties(Fader, {
|
|||
super.cacheCanvasStyle(style)
|
||||
|
||||
var size = this.getProp('horizontal') ? this.width : this.height
|
||||
this.cssVars.knobSize = this.thumbSize * size
|
||||
this.cssVars.knobSize = Math.max(this.thumbSize * size, 30)
|
||||
this.cssVars.alphaKnob = 0.25
|
||||
|
||||
}
|
||||
|
|
@ -132,8 +141,6 @@ export default class Scrollbar extends StaticProperties(Fader, {
|
|||
|
||||
this.scrollTarget = target
|
||||
|
||||
// listen for cloneTarget's deletion
|
||||
// if it is just edited, its recreation will be caught by the global 'widget-created' event handler
|
||||
this.scrollTarget.on('widget-removed', (e)=>{
|
||||
if (this.scrollTarget === e.widget) {
|
||||
this.unbindTarget()
|
||||
|
|
@ -147,8 +154,8 @@ export default class Scrollbar extends StaticProperties(Fader, {
|
|||
size = this.getProp('horizontal') ? this.width : this.height
|
||||
|
||||
this.thumbSize = this.scrollTarget.scrollThumb[index]
|
||||
this.cssVars.knobSize = this.thumbSize * size
|
||||
this.setValue(this.scrollTarget.scroll[index], {fromPanel:true, script:true})
|
||||
this.cssVars.knobSize = Math.max(this.thumbSize * size, 30)
|
||||
this.setValue(this.scrollTarget.scroll[index], {fromPanel:true, send:true, sync:true})
|
||||
}
|
||||
|
||||
this.scrollTarget.on('scroll', onScroll)
|
||||
|
|
@ -166,9 +173,9 @@ export default class Scrollbar extends StaticProperties(Fader, {
|
|||
|
||||
if (!options.fromPanel && this.scrollTarget) {
|
||||
if (this.getProp('horizontal')) {
|
||||
this.scrollTarget.setScroll(this.value, undefined, true)
|
||||
this.scrollTarget.setScroll(this.value, undefined, !options.fromPanel)
|
||||
} else {
|
||||
this.scrollTarget.setScroll(undefined, this.value, true)
|
||||
this.scrollTarget.setScroll(undefined, this.value, !options.fromPanel)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue