Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
J
jasette-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
jasette-facil
Validations
8980aa80
Valider
8980aa80
rédigé
7 years ago
par
Nolan Lawson
Validation de
Eugen Rochko
7 years ago
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Fix reduced motion breaking public galleries (#5423)
parent
34118169
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
app/javascript/mastodon/features/ui/util/optional_motion.js
+40
-18
40 ajouts, 18 suppressions
app/javascript/mastodon/features/ui/util/optional_motion.js
app/views/layouts/application.html.haml
+1
-0
1 ajout, 0 suppression
app/views/layouts/application.html.haml
avec
41 ajouts
et
18 suppressions
app/javascript/mastodon/features/ui/util/optional_motion.js
+
40
−
18
Voir le fichier @
8980aa80
// Like react-motion's Motion, but checks to see if the user prefers
// Like react-motion's Motion, but checks to see if the user prefers
// reduced motion and uses a cross-fade in those cases.
// reduced motion and uses a cross-fade in those cases.
import
React
from
'
react
'
;
import
Motion
from
'
react-motion/lib/Motion
'
;
import
Motion
from
'
react-motion/lib/Motion
'
;
import
{
connect
}
from
'
react-redux
'
;
import
PropTypes
from
'
prop-types
'
;
const
stylesToKeep
=
[
'
opacity
'
,
'
backgroundOpacity
'
];
const
stylesToKeep
=
[
'
opacity
'
,
'
backgroundOpacity
'
];
let
reduceMotion
;
const
extractValue
=
(
value
)
=>
{
const
extractValue
=
(
value
)
=>
{
// This is either an object with a "val" property or it's a number
// This is either an object with a "val" property or it's a number
return
(
typeof
value
===
'
object
'
&&
value
&&
'
val
'
in
value
)
?
value
.
val
:
value
;
return
(
typeof
value
===
'
object
'
&&
value
&&
'
val
'
in
value
)
?
value
.
val
:
value
;
};
};
const
mapStateToProps
=
(
state
,
ownProps
)
=>
{
class
OptionalMotion
extends
React
.
Component
{
const
reduceMotion
=
state
.
getIn
([
'
meta
'
,
'
reduce_motion
'
]);
if
(
reduceMotion
)
{
const
{
style
,
defaultStyle
}
=
ownProps
;
Object
.
keys
(
style
).
forEach
(
key
=>
{
static
propTypes
=
{
if
(
stylesToKeep
.
includes
(
key
))
{
defaultStyle
:
PropTypes
.
object
,
return
;
style
:
PropTypes
.
object
,
}
children
:
PropTypes
.
func
,
// If it's setting an x or height or scale or some other value, we need
}
// to preserve the end-state value without actually animating it
style
[
key
]
=
defaultStyle
[
key
]
=
extractValue
(
style
[
key
]);
});
return
{
style
,
defaultStyle
};
render
()
{
const
{
style
,
defaultStyle
,
children
}
=
this
.
props
;
if
(
typeof
reduceMotion
!==
'
boolean
'
)
{
// This never changes without a page reload, so we can just grab it
// once from the body classes as opposed to using Redux's connect(),
// which would unnecessarily update every state change
reduceMotion
=
document
.
body
.
classList
.
contains
(
'
reduce-motion
'
);
}
if
(
reduceMotion
)
{
Object
.
keys
(
style
).
forEach
(
key
=>
{
if
(
stylesToKeep
.
includes
(
key
))
{
return
;
}
// If it's setting an x or height or scale or some other value, we need
// to preserve the end-state value without actually animating it
style
[
key
]
=
defaultStyle
[
key
]
=
extractValue
(
style
[
key
]);
});
}
return
(
<
Motion
style
=
{
style
}
defaultStyle
=
{
defaultStyle
}
>
{
children
}
<
/Motion
>
);
}
}
return
{};
};
export
default
connect
(
mapStateToProps
)(
Motion
);
}
export
default
OptionalMotion
;
Ce diff est replié.
Cliquez pour l'agrandir.
app/views/layouts/application.html.haml
+
1
−
0
Voir le fichier @
8980aa80
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
=
yield
:header_tags
=
yield
:header_tags
-
body_classes
||=
@body_classes
||
''
-
body_classes
||=
@body_classes
||
''
-
body_classes
+=
' reduce-motion'
if
current_account
&
.
user
&
.
setting_reduce_motion
-
body_classes
+=
' system-font'
if
current_account
&
.
user
&
.
setting_system_font_ui
-
body_classes
+=
' system-font'
if
current_account
&
.
user
&
.
setting_system_font_ui
%body
{
class:
add_rtl_body_class
(
body_classes
)
}
%body
{
class:
add_rtl_body_class
(
body_classes
)
}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter