File: flashspot.js

package info (click to toggle)
cinnamon 3.2.7-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 11,624 kB
  • sloc: ansic: 33,269; python: 18,048; xml: 1,504; makefile: 780; sh: 90; cpp: 54
file content (53 lines) | stat: -rw-r--r-- 1,518 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-

const Lang = imports.lang;

const Lightbox = imports.ui.lightbox;
const Main = imports.ui.main;
const Tweener = imports.ui.tweener;

const FLASHSPOT_ANIMATION_TIME = 0.15; // seconds

function Flashspot(area) {
   this._init(area);
}
Flashspot.prototype = {
   __proto__: Lightbox.Lightbox.prototype,

   _init: function(area) {
      Lightbox.Lightbox.prototype._init.call(this, Main.uiGroup, {
         inhibitEvents: true,
         width: area.width,
         height: area.height
      });
      this.actor.style_class = 'flashspot';
      this.actor.set_position(area.x, area.y);
      if (area.time)
        this.animation_time = area.time;
      else
        this.animation_time = FLASHSPOT_ANIMATION_TIME;
   },

   fire: function() {
      this.actor.opacity = 0;
      Tweener.addTween(this.actor,
                      { opacity: 255,
                        time: this.animation_time,
                        transition: 'linear',
                        onComplete: Lang.bind(this, this._onFireShowComplete)
                      });
      this.actor.show();
   },

   _onFireShowComplete: function() {
      Tweener.addTween(this.actor,
                      { opacity: 0,
                        time: this.animation_time,
                        transition: 'linear',
                        onComplete: Lang.bind(this, function() {
                            this.destroy();
                        })
                      });
   }
};