File tree 2 files changed +26
-2
lines changed
skins/vector/views/molecules
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change
1
+ var Velocity = require ( 'velocity-animate' ) ;
2
+
3
+ // courtesy of https://github.com/julianshapiro/velocity/issues/283
4
+ // We only use easeOutBounce (easeInBounce is just sort of nonsensical)
5
+ function bounce ( p ) {
6
+ var pow2 ,
7
+ bounce = 4 ;
8
+
9
+ while ( p < ( ( pow2 = Math . pow ( 2 , -- bounce ) ) - 1 ) / 11 ) { }
10
+ return 1 / Math . pow ( 4 , 3 - bounce ) - 7.5625 * Math . pow ( ( pow2 * 3 - 2 ) / 22 - p , 2 ) ;
11
+ }
12
+
13
+ Velocity . Easings . easeOutBounce = function ( p ) {
14
+ return 1 - bounce ( 1 - p ) ;
15
+ }
Original file line number Diff line number Diff line change @@ -29,6 +29,15 @@ var ContextualMenu = require('../../../../ContextualMenu');
29
29
var TextForEvent = require ( 'matrix-react-sdk/lib/TextForEvent' ) ;
30
30
31
31
var Velociraptor = require ( '../../../../Velociraptor' ) ;
32
+ require ( '../../../../VelocityBounce' ) ;
33
+
34
+ var bounce = false ;
35
+ try {
36
+ if ( global . localStorage ) {
37
+ bounce = global . localStorage . getItem ( 'avatar_bounce' ) == 'true' ;
38
+ }
39
+ } catch ( e ) {
40
+ }
32
41
33
42
var eventTileTypes = {
34
43
'm.room.message' : 'molecules.MessageTile' ,
@@ -137,8 +146,8 @@ module.exports = React.createClass({
137
146
// and then it will drop down to its resting position
138
147
startStyles . push ( { top : topOffset , left : '0px' } ) ;
139
148
enterTransitionOpts . push ( {
140
- duration : 300 ,
141
- easing : 'easeOutCubic' ,
149
+ duration : bounce ? Math . min ( Math . log ( Math . abs ( topOffset ) ) * 200 , 3000 ) : 300 ,
150
+ easing : bounce ? 'easeOutBounce' : 'easeOutCubic' ,
142
151
} ) ;
143
152
}
144
153
You can’t perform that action at this time.
0 commit comments