使用 Famo.us/Angular 创建并转换为负 Z 位置的表面不会ng-click
在 Chrome 中接收事件。这似乎是一个已知的WebKit 错误,在 Firefox 中不是问题;请参阅下面的 Plunker 中的示例。
现在我想要一组沿 Z 轴进出浮动的表面,并且能够单击其中任何一个将其带到前台,当它们具有较大的负 Z 值时,这在 Chrome 中是一个问题.
我可以将表面设置fa-pipe-to
为 EventHandler,但事件数据似乎不包含有关事件源的信息,因此我无法准确识别单击了哪个表面。
什么是实现这种在 Chrome 中运行良好的行为的好方法?
Famo.us元素周期表演示实现了与我的想法类似的行为:表面在其中浮动,它在 Chrome 中运行良好。那里是怎么做的?...无法从缩小的代码中弄清楚这一点。
Unity 游戏引擎提供了光线投射功能,您可以在其中通过鼠标点击获得物体。也许我应该实现类似的东西,但我的猜测是元素周期表演示中的拾取表面是以更简单的方式完成的。他们是否可能只是确保表面保持在正 Z 位置?
这是一个在 Z=0 处呈现红色方块的示例,它在 Chrome 中接收点击事件,而在 Z=-200 处呈现的绿色方块不会收到点击事件,除非您将在 Firefox 中运行该示例:
http://plnkr.co/edit/UZp4oB?p=preview
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Clicking on Famo.us surfaces in deep z-space</title>
<link href="famous-angular.css" rel="stylesheet" type="text/css">
<link href="style.css" rel="stylesheet" type="text/css">
<script src="https://code.famo.us/famous/global/0.2.2/famous.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>
<script src="famous-angular.js"></script>
</head>
<body ng-app="faScrollViewExampleApp">
<fa-app ng-controller="ScrollCtrl" fa-perspective="1000">
<fa-view ng-repeat="surface in surfaces">
<fa-modifier fa-size="[200, 200]"
fa-translate="[200*$index, 200*$index, surface.zIndex]">
<fa-surface fa-background-color="surface.color"
ng-click="surfaceClick($index)">
I'm in z = {{surface.zIndex}}
</fa-surface>
</fa-modifier>
</fa-view>
</fa-app>
<script>
angular.module('faScrollViewExampleApp', ['famous.angular'])
.controller('ScrollCtrl', ['$scope', '$famous', function($scope, $famous) {
$scope.surfaces = [
{color: 'red', zIndex: 0},
{color: 'green', zIndex: -200} ];
$scope.surfaceClick = function( index ) {
alert( "index " + index + " clicked");
}
}]);
</script>
</body>
</html>