Skip to content

Commit 122df77

Browse files
committed
feat: add config to toggle Tabber animation and default to false
Add a config to enable/disable Tabber scrolling animation. It is currently default to false as smooth scrolling is broken on Safari, as tabs would not scroll at all with it on. It is an upstream browser bug that is being tracked here: https://bugs.webkit.org/show_bug.cgi?id=238497
1 parent 45dc6fa commit 122df77

4 files changed

Lines changed: 31 additions & 7 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,10 @@ First Page Name|First Tab Title
8989
Second Page Name|Second Tab Title
9090
Third Page Name|Third Tab Title
9191
</tabbertransclude>
92-
```
92+
```
93+
94+
## Configurations
95+
Name | Description | Values | Default
96+
:--- | :--- | :--- | :---
97+
`$wgTabberNeueEnableAnimation` | Enable or disable smooth scroll animation |`true` - enable; `false` - disable | `false`
98+
`$wgTabberNeueUpdateLocationOnTabChange` | If enabled, when a tab is selected, the URL displayed on the browser changes. Opening this URL makes that tab initially selected |`true` - enable; `false` - disable | `true`

extension.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
{
3434
"name": "config.json",
3535
"config": {
36+
"enableAnimation": "TabberNeueEnableAnimation",
3637
"updateLocationOnTabChange": "TabberNeueUpdateLocationOnTabChange"
3738
}
3839
}
@@ -108,6 +109,11 @@
108109
},
109110
"config_prefix": "wg",
110111
"config": {
112+
"TabberNeueEnableAnimation": {
113+
"value": false,
114+
"description": "Enable or disable smooth scroll animation",
115+
"public": true
116+
},
111117
"TabberNeueUpdateLocationOnTabChange": {
112118
"value": true,
113119
"description": "If enabled, when a tab is selected, the URL displayed on the browser changes. Opening this URL makes that tab initially selected.",

modules/ext.tabberNeue.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,16 @@ function initTabber( tabber, count ) {
153153
updateButtons();
154154
} );
155155

156+
// Add class to enable animation
157+
// TODO: Change default to true when Safari bug is resolved
158+
//
159+
// Safari does not scroll when scroll-behavior: smooth and overflow: hidden
160+
// Therefore the default is set to false now until it gets resolved
161+
// https://bugs.webkit.org/show_bug.cgi?id=238497
162+
if ( !config || config.enableAnimation ) {
163+
tabber.classList.add( 'tabber--animate' );
164+
}
165+
156166
// Listen for element resize
157167
if ( window.ResizeObserver ) {
158168
var tabListResizeObserver = new ResizeObserver( mw.util.debounce( 250, setupButtons ) );
@@ -380,4 +390,4 @@ if ( document.readyState === 'interactive' || document.readyState === 'complete'
380390
document.addEventListener( 'DOMContentLoaded', function () {
381391
main();
382392
} );
383-
};
393+
}

modules/ext.tabberNeue.less

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,13 @@
237237
// Smooth scrolling through a large number of panels hurt performance on mobile
238238
// Also it will trigger unnessecary lazyloading as lazyload content show up momentarily
239239
@media ( prefers-reduced-motion: no-preference ) and ( min-width: 720px ) {
240-
.tabber {
241-
&__header,
242-
&__section,
243-
&__tabs {
244-
scroll-behavior: smooth;
240+
.tabber--animate {
241+
.tabber {
242+
&__header,
243+
&__section,
244+
&__tabs {
245+
scroll-behavior: smooth;
246+
}
245247
}
246248
}
247249
}

0 commit comments

Comments
 (0)