UNPKG

five-bells-visualization

Version:
110 lines (88 loc) 2.9 kB
<!doctype html> <!-- Copyright (c) 2014 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt --> <html> <head> <meta charset="UTF-8"> <title>paper-ripple position tests</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> <script src="../../webcomponentsjs/webcomponents.js"></script> <script src="../../web-component-tester/browser.js"></script> <script src="../../polymer-gestures/test/js/fake.js"></script> <link href="../paper-ripple.html" rel="import"> <style> .ripple-container { border: 1px solid black; position: relative; margin: 16px; } .ripple-container > span { pointer-events: none; } .ripple-1 { width: 320px; height: 480px; } .ripple-1-tap { top: 10px; } .ripple-2 { width: 480px; height: 320px; } .ripple-2-tap { pointer-events: none; } .ripple-3 { width: 320px; height: 320px; } </style> </head> <body unresolved> <div class="ripple-container ripple-1" layout vertical center> <paper-ripple fit></paper-ripple> <span class="ripple-1-tap">tap here</span> </div> <div class="ripple-container ripple-2" layout horizontal center> <paper-ripple fit></paper-ripple> <span class="ripple-2-tap">tap here</span> </div> <script> var fake = new Fake(); function centerOf(node) { var rect = node.getBoundingClientRect(); return {x: rect.left + rect.width / 2, y: rect.top + rect.height / 2}; } function approxEqual(p1, p2) { return Math.floor(p1.x) == Math.floor(p2.x) && Math.floor(p1.y) == Math.floor(p2.y); } test('tall container', function(done) { var ripple1 = document.querySelector('.ripple-1-tap'); fake.downOnNode(ripple1, function() { requestAnimationFrame(function() { var wave = document.querySelector('.ripple-1 /deep/ .wave'); assert.ok(approxEqual(centerOf(ripple1), centerOf(wave))); done(); }); }); }); test('wide container', function(done) { var ripple2 = document.querySelector('.ripple-2-tap'); fake.downOnNode(ripple2, function() { requestAnimationFrame(function() { var wave = document.querySelector('.ripple-2 /deep/ .wave'); assert.ok(approxEqual(centerOf(ripple2), centerOf(wave))); done(); }); }); }); </script> </body> </html>