client: remove iOS scrollbar shim

This commit is contained in:
jean-emmanuel 2025-09-19 08:37:28 +02:00
parent 007ff1e7fd
commit 3ca713ecf6
6 changed files with 3 additions and 111 deletions

View file

@ -20,6 +20,7 @@
- breaking change
- dropped support for iOS 10.3
- scrollbars are no longer emulated iOS
## 1.29.8

View file

@ -1,5 +1,4 @@
import UiWidget from './ui-widget.mjs'
import {setScrollbarColor} from './utils.mjs'
class UiWorkspace extends UiWidget {
@ -7,8 +6,6 @@ class UiWorkspace extends UiWidget {
super(options)
setScrollbarColor(this.container)
}
}

View file

@ -1,4 +1,3 @@
import chroma from 'chroma-js'
import fastdom from 'fastdom'
import {DOM} from '../globals.mjs'
@ -11,36 +10,6 @@ export function iconify(string){
return String(string).replace(/\^[^\s]{2,}/g,(x)=>{return icon(x.substring(1))})
}
export function setScrollbarColor(container) {
fastdom.measure(()=>{
var computedStyle = window.getComputedStyle(container),
alpha = parseFloat(computedStyle.getPropertyValue('--alpha-scrollbar')),
alphaOn = parseFloat(computedStyle.getPropertyValue('--alpha-scrollbar-on')),
color = computedStyle.getPropertyValue('--color-fill').trim()
if (color === 'transparent') {
// prevent chroma-js error
// irrelevant case, but still...
color = 'rgb(0, 0, 0)'
alpha = 0
alphaOn = 0
}
if (color) {
fastdom.mutate(()=>{
try {
container.style.setProperty('--color-scrollbar', chroma(color).alpha(alpha).css())
container.style.setProperty('--color-scrollbar-on', chroma(color).alpha(alphaOn).css())
} catch(e) {}
})
}
})
}
export function updateMobileThemeColor(root) {
fastdom.measure(()=>{

View file

@ -4,11 +4,8 @@ import Panel from './panel.mjs'
import {icon, iconify} from '../../ui/utils.mjs'
import * as resize from '../../events/resize.mjs'
import doubleTap from '../mixins/double_tap'
import iOS from '../../ui/ios.mjs'
import {DOM, PXSCALE} from '../../globals.mjs'
var iOS13 = iOS === 13
class Modal extends Panel {
static description() {
@ -73,13 +70,6 @@ class Modal extends Panel {
this.popupContent = DOM.get(this.popup, '.popup-content')[0]
if (iOS13 && this.getProp('scroll')) {
for (let dir in this.iosScrollbars) {
this.container.removeChild(this.iosScrollbars[dir].container)
this.popupContent.appendChild(this.iosScrollbars[dir].container)
}
}
// convert dimensions / coordinates to rem
var geometry = {}
for (var g of ['Width', 'Height', 'Left', 'Top']) {

View file

@ -4,16 +4,10 @@ import Container from '../common/container.mjs'
import widgetManager from '../../managers/widgets.mjs'
import parser from '../../parser.mjs'
import {enableTraversingGestures, disableTraversingGestures} from '../../events/drag.mjs'
import {setScrollbarColor} from '../../ui/utils.mjs'
import iOS from '../../ui/ios.mjs'
import Fader from '../sliders/fader.mjs'
import Script from '../scripts/script.mjs'
import * as resize from '../../events/resize'
import {DOM} from '../../globals.mjs'
var iOS13 = iOS === 13,
faderDefaults
class Panel extends Container() {
static description() {
@ -106,52 +100,6 @@ class Panel extends Container() {
if (this.getProp('scroll')) {
if (iOS13) {
faderDefaults = faderDefaults || Fader.defaults()._props()
this.iosScrollbars = {}
for (let dir of ['vertical', 'horizontal']) {
this.iosScrollbars[dir] = new Fader({props:{
...faderDefaults,
design:'compact',
horizontal: dir === 'horizontal',
range: dir === 'horizontal' ? {min:0, max:1} : {min:1, max:0}
}, parent: this})
this.iosScrollbars[dir].container.classList.add('not-editable')
this.iosScrollbars[dir].container.classList.add('ios-scrollbar')
this.iosScrollbars[dir].container.classList.add(dir)
this.iosScrollbars[dir]._scrollable = false
this.container.appendChild(this.iosScrollbars[dir].container)
}
this.iosScrollbars.horizontal.on('value-changed', (e)=>{
e.stopPropagation = true
this.setScroll(parseInt(e.widget.getValue() * (this.widget.scrollWidth - this.widget.clientWidth)), undefined, true)
})
this.iosScrollbars.vertical.on('value-changed', (e)=>{
e.stopPropagation = true
this.setScroll(undefined, parseInt(e.widget.getValue() * (this.widget.scrollWidth - this.widget.clientWidth)), true)
})
this.checkScrollBars = ()=>{
this.iosScrollbars.horizontal.container.style.setProperty('--knob-size', parseInt(this.widget.clientWidth * this.widget.clientWidth / this.widget.scrollWidth) + 'px')
this.iosScrollbars.vertical.container.style.setProperty('--knob-size', parseInt(this.widget.clientHeight * this.widget.clientHeight / this.widget.scrollHeight) + 'px')
this.iosScrollbars.horizontal._scrollable = this.container.classList.toggle('has-ios-scrollbar-h', this.widget.scrollWidth > this.widget.clientWidth)
this.iosScrollbars.vertical._scrollable = this.container.classList.toggle('has-ios-scrollbar-v', this.widget.scrollHeight > this.widget.clientHeight)
this.iosScrollbars.vertical.container.classList.toggle('double-scrollbar', this.iosScrollbars.horizontal._scrollable && this.iosScrollbars.vertical._scrollable)
if (this.iosScrollbars.horizontal._scrollable) resize.check(this.iosScrollbars.horizontal.container, true)
if (this.iosScrollbars.vertical._scrollable) resize.check(this.iosScrollbars.vertical.container, true)
this.iosScrollbars.horizontal.batchDraw()
}
this.on('resize', (event)=>{
this.checkScrollBars()
}, {element: this.widget})
}
if (this.props.type !== 'modal') {
this.value = [0, 0]
this.scrollTimeout = null
@ -171,10 +119,6 @@ class Panel extends Container() {
this.scroll = [this.widget.scrollLeft, this.widget.scrollTop]
var x = this.widget.scrollLeft / this.scrollWidth || 0,
y = this.widget.scrollTop / this.scrollHeight || 0
if (iOS13) {
if (this.iosScrollbars.horizontal._scrollable) this.iosScrollbars.horizontal.setValue(x)
if (this.iosScrollbars.vertical._scrollable) this.iosScrollbars.vertical.setValue(y)
}
if (this.props.type !== 'modal') {
if (this.settingScroll) {
clearTimeout(this.settingScrollEnd)
@ -405,8 +349,6 @@ class Panel extends Container() {
this.setCssVariables()
// falls through
case 'colorWidget':
if (iOS13 && this.getProp('scroll')) this.checkScrollBars()
// falls through
case 'colorText':
case 'colorFill':
case 'colorStroke':
@ -423,13 +365,6 @@ class Panel extends Container() {
}
setCssVariables() {
super.setCssVariables()
setScrollbarColor(this.container)
}
setTraversing(update) {
var traversing = this.getProp('traversing')

View file

@ -1,4 +1,4 @@
// Chromium
// Legacy chromium
::-webkit-scrollbar {
width: var(--scrollbar-size);
@ -40,7 +40,7 @@
}
// Firefox
// Modern browsers
* {
scrollbar-color: var(--color-scrollbar) var(--color-background);