mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
+ Added Math.tanh by way of utils
+ Added a minimum and maximum scale
This commit is contained in:
parent
fe2a93f8b1
commit
600f65520e
@ -65,6 +65,9 @@ window.TabItem.prototype = $.extend(new Item(), {
|
||||
var $close = $('.close', $container);
|
||||
var extra = this._getSizeExtra();
|
||||
var css = {};
|
||||
|
||||
const minFontSize = 6;
|
||||
const maxFontSize = 15;
|
||||
|
||||
if(rect.left != this.bounds.left)
|
||||
css.left = rect.left;
|
||||
@ -75,10 +78,11 @@ window.TabItem.prototype = $.extend(new Item(), {
|
||||
if(rect.width != this.bounds.width) {
|
||||
css.width = rect.width - extra.x;
|
||||
var scale = css.width / TabItems.tabWidth;
|
||||
css.fontSize = TabItems.fontSize * scale;
|
||||
if( css.fontSize < 10 ){
|
||||
css.fontSize = 10;
|
||||
}
|
||||
|
||||
// The ease function ".5+.5*Math.tanh(2*x-2)" is a pretty
|
||||
// little graph. It goes from near 0 at x=0 to near 1 at x=2
|
||||
// smoothly and beautifully.
|
||||
css.fontSize = minFontSize + (maxFontSize-minFontSize)*(.5+.5*Math.tanh(2*scale-2))
|
||||
}
|
||||
|
||||
if(rect.height != this.bounds.height) {
|
||||
@ -93,14 +97,6 @@ window.TabItem.prototype = $.extend(new Item(), {
|
||||
if(immediately) {
|
||||
$container.css(css);
|
||||
|
||||
/*
|
||||
if(css.fontSize) {
|
||||
if(css.fontSize < 8)
|
||||
$title.hide();
|
||||
else
|
||||
$title.show();
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
TabMirror.pausePainting();
|
||||
$container.animate(css, {complete: function() {
|
||||
@ -109,7 +105,7 @@ window.TabItem.prototype = $.extend(new Item(), {
|
||||
}
|
||||
|
||||
if(css.fontSize) {
|
||||
if(css.fontSize < 8)
|
||||
if(css.fontSize < minFontSize)
|
||||
$title.fadeOut();
|
||||
else
|
||||
$title.fadeIn();
|
||||
|
@ -420,4 +420,9 @@ var Utils = {
|
||||
|
||||
window.Utils = Utils;
|
||||
|
||||
window.Math.tanh = function tanh(x){
|
||||
var e = Math.exp(x);
|
||||
return (e - 1/e) / (e + 1/e);
|
||||
}
|
||||
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user