1<!doctype html>
2<!--
3Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7Code distributed by Google as part of the polymer project is also
8subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9-->
10<html>
11<head>
12
13  <meta charset="UTF-8">
14  <title>paper-ripple position tests</title>
15  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
16
17  <script src="../../webcomponentsjs/webcomponents.js"></script>
18  <script src="../../web-component-tester/browser.js"></script>
19  <script src="../../polymer-gestures/test/js/fake.js"></script>
20
21  <link href="../paper-ripple.html" rel="import">
22
23  <style>
24    .ripple-container {
25      border: 1px solid black;
26      position: relative;
27      margin: 16px;
28    }
29
30    .ripple-container > span {
31      pointer-events: none;
32    }
33
34    .ripple-1 {
35      width: 320px;
36      height: 480px;
37    }
38
39    .ripple-1-tap {
40      top: 10px;
41    }
42
43    .ripple-2 {
44      width: 480px;
45      height: 320px;
46    }
47
48    .ripple-2-tap {
49      pointer-events: none;
50    }
51
52    .ripple-3 {
53      width: 320px;
54      height: 320px;
55    }
56  </style>
57
58</head>
59<body unresolved>
60
61  <div class="ripple-container ripple-1" layout vertical center>
62    <paper-ripple fit></paper-ripple>
63    <span class="ripple-1-tap">tap here</span>
64  </div>
65
66  <div class="ripple-container ripple-2" layout horizontal center>
67    <paper-ripple fit></paper-ripple>
68    <span class="ripple-2-tap">tap here</span>
69  </div>
70
71  <script>
72    var fake = new Fake();
73
74    function centerOf(node) {
75      var rect = node.getBoundingClientRect();
76      return {x: rect.left + rect.width / 2, y: rect.top + rect.height / 2};
77    }
78
79    function approxEqual(p1, p2) {
80      return Math.floor(p1.x) == Math.floor(p2.x) && Math.floor(p1.y) == Math.floor(p2.y);
81    }
82
83    test('tall container', function(done) {
84      var ripple1 = document.querySelector('.ripple-1-tap');
85      fake.downOnNode(ripple1, function() {
86        requestAnimationFrame(function() {
87          var wave = document.querySelector('.ripple-1 /deep/ .wave');
88          assert.ok(approxEqual(centerOf(ripple1), centerOf(wave)));
89          done();
90        });
91      });
92    });
93
94    test('wide container', function(done) {
95      var ripple2 = document.querySelector('.ripple-2-tap');
96      fake.downOnNode(ripple2, function() {
97        requestAnimationFrame(function() {
98          var wave = document.querySelector('.ripple-2 /deep/ .wave');
99          assert.ok(approxEqual(centerOf(ripple2), centerOf(wave)));
100          done();
101        });
102
103      });
104    });
105
106  </script>
107
108</body>
109</html>
110