forked from matrix/element-web
Hidden localstorage option to enable bouncy read receipts :p
This commit is contained in:
parent
23d45d7f33
commit
0dd85d9adf
|
@ -0,0 +1,15 @@
|
||||||
|
var Velocity = require('velocity-animate');
|
||||||
|
|
||||||
|
// courtesy of https://github.com/julianshapiro/velocity/issues/283
|
||||||
|
// We only use easeOutBounce (easeInBounce is just sort of nonsensical)
|
||||||
|
function bounce( p ) {
|
||||||
|
var pow2,
|
||||||
|
bounce = 4;
|
||||||
|
|
||||||
|
while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
|
||||||
|
return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
Velocity.Easings.easeOutBounce = function(p) {
|
||||||
|
return 1 - bounce(1 - p);
|
||||||
|
}
|
|
@ -29,6 +29,15 @@ var ContextualMenu = require('../../../../ContextualMenu');
|
||||||
var TextForEvent = require('matrix-react-sdk/lib/TextForEvent');
|
var TextForEvent = require('matrix-react-sdk/lib/TextForEvent');
|
||||||
|
|
||||||
var Velociraptor = require('../../../../Velociraptor');
|
var Velociraptor = require('../../../../Velociraptor');
|
||||||
|
require('../../../../VelocityBounce');
|
||||||
|
|
||||||
|
var bounce = false;
|
||||||
|
try {
|
||||||
|
if (global.localStorage) {
|
||||||
|
bounce = global.localStorage.getItem('avatar_bounce') == 'true';
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
|
||||||
var eventTileTypes = {
|
var eventTileTypes = {
|
||||||
'm.room.message': 'molecules.MessageTile',
|
'm.room.message': 'molecules.MessageTile',
|
||||||
|
@ -137,8 +146,8 @@ module.exports = React.createClass({
|
||||||
// and then it will drop down to its resting position
|
// and then it will drop down to its resting position
|
||||||
startStyles.push({ top: topOffset, left: '0px' });
|
startStyles.push({ top: topOffset, left: '0px' });
|
||||||
enterTransitionOpts.push({
|
enterTransitionOpts.push({
|
||||||
duration: 300,
|
duration: bounce ? Math.min(Math.log(Math.abs(topOffset)) * 200, 3000) : 300,
|
||||||
easing: 'easeOutCubic',
|
easing: bounce ? 'easeOutBounce' : 'easeOutCubic',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue