@@ -118,7 +118,7 @@ export default async function({ addon }) {
118
118
animateButtons = addon . settings . get ( "animateButtons" ) ;
119
119
120
120
const oldSpeed = animationSpeed ;
121
- animationSpeed = Number ( addon . settings . get ( "animateSpeed" ) ) / 100 ;
121
+ animationSpeed = 5 - ( Number ( addon . settings . get ( "animateSpeed" ) ) / 100 ) ;
122
122
if ( oldSpeed !== animationSpeed ) styleElement . textContent = genStyles ( ) ;
123
123
}
124
124
@@ -158,7 +158,6 @@ export default async function({ addon }) {
158
158
}
159
159
160
160
function handleOpenAnimation ( elementName ) {
161
- requestAddonState ( ) ;
162
161
const type = elementName . endsWith ( "Library" ) ? "library" : elementName . endsWith ( "Menu" ) ? "menu" : "modal" ;
163
162
164
163
if ( ! animateLibraries && type === "library" ) return ;
@@ -190,7 +189,7 @@ export default async function({ addon }) {
190
189
191
190
const animation = element . animate (
192
191
[ { height : "0px" , opacity : 0 } , { height : `${ ogHeight } px` , opacity : 1 } ] ,
193
- { duration : animTime , easing : cubicAnimation }
192
+ { duration : animTime * animationSpeed , easing : cubicAnimation }
194
193
) ;
195
194
animation . onfinish = ( ) => {
196
195
element . style . overflow = "hidden" ;
@@ -208,12 +207,11 @@ export default async function({ addon }) {
208
207
209
208
element . animate (
210
209
[ { transform : "scale(0)" , opacity : 0 } , { transform : "scale(1)" , opacity : 1 } ] ,
211
- { duration : animTime , easing : cubicAnimation }
210
+ { duration : animTime * animationSpeed , easing : cubicAnimation }
212
211
) ;
213
212
}
214
213
215
214
function attachCloseHijack ( elementName ) {
216
- requestAddonState ( ) ;
217
215
const type = elementName . endsWith ( "Library" ) ? "library" : elementName . endsWith ( "Menu" ) ? "menu" : "modal" ;
218
216
if ( type === "menu" || patchedBody ) return ;
219
217
@@ -228,7 +226,6 @@ export default async function({ addon }) {
228
226
229
227
let animTime = 200 ;
230
228
patchedBody = true ;
231
-
232
229
if ( child === element ) {
233
230
const child = element . firstChild ;
234
231
if ( child ) {
@@ -247,11 +244,11 @@ export default async function({ addon }) {
247
244
248
245
animClone . animate (
249
246
[ { opacity : 1 } , { opacity : 0 } ] ,
250
- { duration : animTime , easing : cubicAnimation }
247
+ { duration : animTime * animationSpeed , easing : cubicAnimation }
251
248
) ;
252
249
const animation = animClone . firstChild . animate (
253
250
[ { transform : "scale(1)" , opacity : 1 } , { transform : "scale(0)" , opacity : 0 } ] ,
254
- { duration : animTime , easing : cubicAnimation }
251
+ { duration : animTime * animationSpeed , easing : cubicAnimation }
255
252
) ;
256
253
animation . onfinish = ( ) => {
257
254
animClone . remove ( ) ;
@@ -267,7 +264,6 @@ export default async function({ addon }) {
267
264
}
268
265
269
266
function compileClasses ( optLibrary ) {
270
- requestAddonState ( ) ;
271
267
if ( ! animateButtons ) return ;
272
268
const classMapper = new Map ( ) ;
273
269
@@ -458,4 +454,16 @@ export default async function({ addon }) {
458
454
}
459
455
460
456
if ( typeof scaffolding === "undefined" ) startListenerWorker ( ) ;
457
+
458
+ addon . settings . addEventListener ( "change" , requestAddonState ) ;
459
+ addon . self . addEventListener ( "disabled" , ( ) => {
460
+ animateModals = false ;
461
+ animateLibraries = false ;
462
+ animateButtons = false ;
463
+ } ) ;
464
+ addon . self . addEventListener ( "reenabled" , ( ) => {
465
+ animateModals = true ;
466
+ animateLibraries = true ;
467
+ animateButtons = true ;
468
+ } ) ;
461
469
}
0 commit comments