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
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">
25 border:
1px solid black;
30 .ripple-container
> span {
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>
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>
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
)));
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
)));