2015-10-05 19 views
0

我正在使用eyeTracker,並且想要更改UI,依賴於Eyetrackerpositon。在AngularJs中的位置

我想在我的網站中定義區域。如果eyeTrackerPosition在該區域內(站立),那麼我想改變該區域的顏色。

在這種情況下,區域是指令。

但是它如何與位置一起工作?因爲我需要比屏幕座標。

你有什麼想法可能嗎?

如何查詢位置是否包含區域?有數組?

回答

0

嗨我使用你建議的方法。

myApp.directive('hasFocus', function ($interval) { 
return { 
    restrict: 'A', 
    scope: { 
    }, 
    templateUrl: '123/Scripts/directives/route.html', 
    link: function (scope, element, attrs) { 
     $interval(function() { 
      var rect = element[0].getBoundingClientRect(); 

      x = rect.left; 
      y = rect.top; 
      w = rect.right - rect.left; 
      h = rect.bottom - rect.top; 

      // element.text(x + ", " + y + ", " + w + ", " + h); 

     }, 3000); 
    } 
    }; 
}); 

它正在工作。

但現在我在我的面板在鏈接的位置。我在route.html中定義的面板。

route.html:

<div class="panel panel-primary"> 

<div class="panel-heading">Panel heading</div>  <!-- i want this position--> 
<div class="panel-body"> 
    <!--table--> 
    <table class="table table-condensed"> 
     <thead> 
      <tr> 
       <th>#</th> 
       <th>First Name</th> 
       <th>Last Name</th> 
       <th>Username</th> 
      </tr> 
     </thead> 
     <tbody> 
      <tr> 
       <td>1</td> 
       <td>Mark</td> 
       <td>Otto</td> 
       <td>@mdo</td> 
      </tr> 
     </tbody> 
    </table> 
</div>