Lightbox: have animation times passed as parameters to show() and hide()
This way it is possible to use the same lightbox with different times. https://bugzilla.gnome.org/show_bug.cgi?id=699112
This commit is contained in:
parent
32613ba544
commit
6b8339e9b4
@ -42,15 +42,11 @@ const Lightbox = new Lang.Class({
|
|||||||
params = Params.parse(params, { inhibitEvents: false,
|
params = Params.parse(params, { inhibitEvents: false,
|
||||||
width: null,
|
width: null,
|
||||||
height: null,
|
height: null,
|
||||||
fadeInTime: null,
|
fadeFactor: DEFAULT_FADE_FACTOR,
|
||||||
fadeOutTime: null,
|
|
||||||
fadeFactor: DEFAULT_FADE_FACTOR
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this._container = container;
|
this._container = container;
|
||||||
this._children = container.get_children();
|
this._children = container.get_children();
|
||||||
this._fadeInTime = params.fadeInTime;
|
|
||||||
this._fadeOutTime = params.fadeOutTime;
|
|
||||||
this._fadeFactor = params.fadeFactor;
|
this._fadeFactor = params.fadeFactor;
|
||||||
this.actor = new St.Bin({ x: 0,
|
this.actor = new St.Bin({ x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
@ -101,14 +97,16 @@ const Lightbox = new Lang.Class({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function() {
|
show: function(fadeInTime) {
|
||||||
|
fadeInTime = fadeInTime || 0;
|
||||||
|
|
||||||
Tweener.removeTweens(this.actor);
|
Tweener.removeTweens(this.actor);
|
||||||
if (this._fadeInTime) {
|
if (fadeInTime != 0) {
|
||||||
this.shown = false;
|
this.shown = false;
|
||||||
this.actor.opacity = 0;
|
this.actor.opacity = 0;
|
||||||
Tweener.addTween(this.actor,
|
Tweener.addTween(this.actor,
|
||||||
{ opacity: 255 * this._fadeFactor,
|
{ opacity: 255 * this._fadeFactor,
|
||||||
time: this._fadeInTime,
|
time: fadeInTime,
|
||||||
transition: 'easeOutQuad',
|
transition: 'easeOutQuad',
|
||||||
onComplete: Lang.bind(this, function() {
|
onComplete: Lang.bind(this, function() {
|
||||||
this.shown = true;
|
this.shown = true;
|
||||||
@ -123,13 +121,15 @@ const Lightbox = new Lang.Class({
|
|||||||
this.actor.show();
|
this.actor.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
hide: function() {
|
hide: function(fadeOutTime) {
|
||||||
|
fadeOutTime = fadeOutTime || 0;
|
||||||
|
|
||||||
this.shown = false;
|
this.shown = false;
|
||||||
Tweener.removeTweens(this.actor);
|
Tweener.removeTweens(this.actor);
|
||||||
if (this._fadeOutTime) {
|
if (fadeOutTime != 0) {
|
||||||
Tweener.addTween(this.actor,
|
Tweener.addTween(this.actor,
|
||||||
{ opacity: 0,
|
{ opacity: 0,
|
||||||
time: this._fadeOutTime,
|
time: fadeOutTime,
|
||||||
transition: 'easeOutQuad',
|
transition: 'easeOutQuad',
|
||||||
onComplete: Lang.bind(this, function() {
|
onComplete: Lang.bind(this, function() {
|
||||||
this.actor.hide();
|
this.actor.hide();
|
||||||
|
@ -1730,8 +1730,6 @@ const MessageTray = new Lang.Class({
|
|||||||
for (let i = 0; i < lightboxContainers.length; i++)
|
for (let i = 0; i < lightboxContainers.length; i++)
|
||||||
this._lightboxes.push(new Lightbox.Lightbox(lightboxContainers[i],
|
this._lightboxes.push(new Lightbox.Lightbox(lightboxContainers[i],
|
||||||
{ inhibitEvents: true,
|
{ inhibitEvents: true,
|
||||||
fadeInTime: ANIMATION_TIME,
|
|
||||||
fadeOutTime: ANIMATION_TIME,
|
|
||||||
fadeFactor: 0.2
|
fadeFactor: 0.2
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -2339,7 +2337,7 @@ const MessageTray = new Lang.Class({
|
|||||||
});
|
});
|
||||||
|
|
||||||
for (let i = 0; i < this._lightboxes.length; i++)
|
for (let i = 0; i < this._lightboxes.length; i++)
|
||||||
this._lightboxes[i].show();
|
this._lightboxes[i].show(ANIMATION_TIME);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
@ -2395,7 +2393,7 @@ const MessageTray = new Lang.Class({
|
|||||||
// This is a no-op in that case.
|
// This is a no-op in that case.
|
||||||
this._grabHelper.ungrab({ actor: this.actor });
|
this._grabHelper.ungrab({ actor: this.actor });
|
||||||
for (let i = 0; i < this._lightboxes.length; i++)
|
for (let i = 0; i < this._lightboxes.length; i++)
|
||||||
this._lightboxes[i].hide();
|
this._lightboxes[i].hide(ANIMATION_TIME);
|
||||||
},
|
},
|
||||||
|
|
||||||
_hideDesktopClone: function() {
|
_hideDesktopClone: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user