1
0
Fork 0
Browse Source

Fix positioning when scrolled

master
Gregory Eremin 8 years ago
parent
commit
17c0c06e97
  1. 4
      background.js
  2. 3
      resources/playground.html

4
background.js

@ -164,14 +164,14 @@ @@ -164,14 +164,14 @@
log('Event: '+ e_left +','+ e_top);
// Default positioning
var t_top = s_top + e_top - t_height - 20,
var t_top = e_top - t_height - 20,
t_left = s_left + e_left - t_width / 2;
log('Initial position: '+ t_left +','+ t_top);
if (t_top < 10) {
// Vertical positioning correction
t_top = 10;
t_top = s_top + 10;
if (e_left > w_width / 2) {
t_left = s_left + e_left - t_width - 20;

3
resources/playground.html

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
<title>Playground</title>
<meta charset="utf8">
<style type="text/css">
body { height: 2000px; }
a { position: absolute; }
#l1{ top: 20px; left: 20px; }
@ -12,6 +13,7 @@ @@ -12,6 +13,7 @@
#l4{ top: 320px; left: 20px; }
#l5{ top: 420px; left: 20px; }
#l6{ top: 420px; left: 320px; }
#l7{ top: 1000px; left: 320px; }
#r1{ top: 20px; right: 20px; }
#r2{ top: 120px; right: 20px; }
@ -29,6 +31,7 @@ @@ -29,6 +31,7 @@
<a id="l4">bad link</a>
<a id="l5" href="../../..">wtf</a>
<a id="l6" href="http://www.aviasales.ru/">aviasales.ru</a>
<a id="l7" href="http://www.aviasales.ru/">aviasales.ru</a>
<a id="r1" href="https://twitter.com/">twitter.com</a>
<a id="r2" href="https://github.com/">github.com</a>

Loading…
Cancel
Save