Port Android relocation packer to chromium build
[chromium-blink-merge.git] / third_party / polymer / components / paper-ripple / test / position.html
blob428b19e0d2e0c413eded2d1410223b79d534502c
1 <!doctype html>
2 <!--
3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9 -->
10 <html>
11 <head>
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">
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>
21 <link href="../paper-ripple.html" rel="import">
23 <style>
24 .ripple-container {
25 border: 1px solid black;
26 position: relative;
27 margin: 16px;
30 .ripple-container > span {
31 pointer-events: none;
34 .ripple-1 {
35 width: 320px;
36 height: 480px;
39 .ripple-1-tap {
40 top: 10px;
43 .ripple-2 {
44 width: 480px;
45 height: 320px;
48 .ripple-2-tap {
49 pointer-events: none;
52 .ripple-3 {
53 width: 320px;
54 height: 320px;
56 </style>
58 </head>
59 <body unresolved>
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>
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>
71 <script>
72 var fake = new Fake();
74 function centerOf(node) {
75 var rect = node.getBoundingClientRect();
76 return {x: rect.left + rect.width / 2, y: rect.top + rect.height / 2};
79 function approxEqual(p1, p2) {
80 return Math.floor(p1.x) == Math.floor(p2.x) && Math.floor(p1.y) == Math.floor(p2.y);
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 });
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();
106 </script>
108 </body>
109 </html>