Skip to content

Commit 0dd85d9

Browse files
committed
Hidden localstorage option to enable bouncy read receipts :p
1 parent 23d45d7 commit 0dd85d9

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/VelocityBounce.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
}

src/skins/vector/views/molecules/EventTile.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ var ContextualMenu = require('../../../../ContextualMenu');
2929
var TextForEvent = require('matrix-react-sdk/lib/TextForEvent');
3030

3131
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+
}
3241

3342
var eventTileTypes = {
3443
'm.room.message': 'molecules.MessageTile',
@@ -137,8 +146,8 @@ module.exports = React.createClass({
137146
// and then it will drop down to its resting position
138147
startStyles.push({ top: topOffset, left: '0px' });
139148
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',
142151
});
143152
}
144153

0 commit comments

Comments
 (0)