This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yvonne Yip
committed
Sep 9, 2014
1 parent
085af70
commit 6ef6e10
Showing
4 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>paper-ripple</title> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> | ||
<meta name="mobile-web-app-capable" content="yes"> | ||
<meta name="apple-mobile-web-app-capable" content="yes"> | ||
|
||
<script src="../../../platform/platform.js"></script> | ||
|
||
<link href="../../paper-ripple.html" rel="import"> | ||
|
||
<script src="../../../polymer-test-tools/chai/chai.js"></script> | ||
<script src="../../../polymer-test-tools/htmltest.js"></script> | ||
<script src="../../../polymer-gestures/test/js/fake.js"></script> | ||
|
||
<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> | ||
|
||
<p>ripple originates from the tap position 1:</p> | ||
<div class="ripple-container ripple-1" layout vertical center> | ||
<paper-ripple fit></paper-ripple> | ||
<span class="ripple-1-tap">tap here</span> | ||
</div> | ||
|
||
<p>ripple originates from the tap position 2:</p> | ||
<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); | ||
} | ||
|
||
function test1() { | ||
var ripple1 = document.querySelector('.ripple-1-tap'); | ||
fake.downOnNode(ripple1, function() { | ||
|
||
requestAnimationFrame(function() { | ||
var wave = document.querySelector('.ripple-1 /deep/ .wave'); | ||
chai.assert(approxEqual(centerOf(ripple1), centerOf(wave)), 'ripple position is incorrect in tall container'); | ||
|
||
test2(); | ||
}); | ||
|
||
}); | ||
} | ||
|
||
function test2() { | ||
var ripple1 = document.querySelector('.ripple-2-tap'); | ||
fake.downOnNode(ripple1, function() { | ||
|
||
requestAnimationFrame(function() { | ||
var wave = document.querySelector('.ripple-2 /deep/ .wave'); | ||
chai.assert(approxEqual(centerOf(ripple1), centerOf(wave)), 'ripple position is incorrect in wide container'); | ||
|
||
done(); | ||
}); | ||
|
||
}); | ||
} | ||
|
||
document.addEventListener('polymer-ready', test1); | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mocha.setup({ui: 'tdd', htmlbase: ''}); | ||
|
||
htmlSuite('paper-ripple', function() { | ||
htmlTest('html/paper-ripple-position.html'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> | ||
<title>Web Component Test Runner</title> | ||
|
||
<link href="../../polymer-test-tools/tools.html" rel="import"> | ||
|
||
<script src="../../polymer-test-tools/mocha-htmltest.js"></script> | ||
<script src="js/htmltests.js"></script> | ||
</head> | ||
<body> | ||
|
||
<div id="mocha"></div> | ||
|
||
<script> | ||
mocha.run(); | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"tools": ["chai", "mocha-tdd"], | ||
"tests": [ | ||
"js/htmltests.js" | ||
] | ||
} |