-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdocument-focus-marker.html
53 lines (45 loc) · 1.18 KB
/
document-focus-marker.html
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
<link rel="import" href="bower_components/polymer/polymer.html">
<dom-module id="document-focus-marker">
<style>
:host{
position: absolute;
top: 0px;
left: 0px;
bottom: 0px;
right: 0px;
border: 20px solid rgba(255,0,0,0.2);
opacity: 0;
pointer-events: none;
};
</style>
<template></template>
<script>
Polymer({
is: 'document-focus-marker',
properties: {
is_focused: {
type: Boolean,
value: true,
notify: true,
readOnly: true
}
}, created: function(){
// bind these methods so we can add/remove easily
}, attached: function(){
var self = this;
window.addEventListener('blur', function(e){
if(e.target === window){
self._setIs_focused(false);
self.style.opacity = '1';
}
}, true);
window.addEventListener('focus', function(){
self._setIs_focused(true);
self.style.opacity = '0';
}, true);
getComputedStyle(this).backgroundColor; // force original 0 opacity to take effect
this.style.transition = 'opacity 2s';
}
});
</script>
</dom-module>