-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generalize polymer's fuoc prevention strategy; fixes: #276
- styling is now expressed via 'polymer-veiled' and 'polymer-unveil' classes which are now user customizable. - to veil (initially hide) an element either include the class 'polymer-veiled' or add to the array: Polymer.veiledElements. This list includes 'body' by default but that can be removed to prevent body from getting de-fuoc'd. - note: Polymer automatically unveils elements at WebComponentsReady time, but elements can be dynamically unveiled by (1) adding the polymer-veiled class to them to hide them and then (2) when they are ready, calling Polymer.unveilElements().
- Loading branch information
Showing
3 changed files
with
151 additions
and
10 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
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,84 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
Copyright 2013 The Polymer Authors. All rights reserved. | ||
Use of this source code is governed by a BSD-style | ||
license that can be found in the LICENSE file. | ||
--> | ||
<html> | ||
<head> | ||
<title>unveil</title> | ||
<script src="../../../polymer.js"></script> | ||
<script src="../../../../tools/test/htmltest.js"></script> | ||
<script src="../../../../tools/test/chai/chai.js"></script> | ||
<style> | ||
.polymer-unveil { | ||
background: red; | ||
} | ||
</style> | ||
<script> | ||
Polymer.veiledElements = ['body', '#veiled']; | ||
</script> | ||
</head> | ||
<body> | ||
<x-test id="veiled"></x-test> | ||
<x-test class="polymer-veiled"></x-test> | ||
|
||
<polymer-element name="x-test"> | ||
<template> | ||
<style> | ||
:host { dispay: block}; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
</style> | ||
x-test | ||
</template> | ||
<script> | ||
Polymer('x-test', { | ||
enteredView: function() { | ||
chai.assert.isTrue(getComputedStyle(this).visibility == 'hidden', | ||
'veiled elements are visible'); | ||
} | ||
}); | ||
</script> | ||
</polymer-element> | ||
|
||
<script> | ||
document.addEventListener('WebComponentsReady', function() { | ||
chai.assert.isTrue(getComputedStyle(document.body).visibility == 'hidden', | ||
'veiled elements are visible'); | ||
// test during transition | ||
requestAnimationFrame(function() { | ||
requestAnimationFrame(function() { | ||
chai.assert.equal(document.querySelectorAll('.polymer-veiled').length, 0, | ||
'element veiled class is removed when unveiling'); | ||
chai.assert.equal(document.querySelectorAll('.polymer-unveil').length, 3, | ||
'element unveil class is applied when unveiling'); | ||
var nodes = document.querySelectorAll('.polymer-unveil') | ||
for (var i=0; i<nodes.length; i++) { | ||
chai.assert.equal(getComputedStyle(nodes[i]).backgroundColor, | ||
'rgb(255, 0, 0)', 'user unveil style is applied'); | ||
} | ||
|
||
}); | ||
}); | ||
var endEvent = (document.documentElement.style.webkitTransition !== undefined) ? | ||
'webkitTransitionEnd' : 'transitionend'; | ||
document.body.addEventListener(endEvent, function(e) { | ||
if (e.target != this) { | ||
return; | ||
} | ||
requestAnimationFrame(function() { | ||
for (var i=0, l=Polymer.veiledElements.length, elt; i<l; i++) { | ||
elt = document.querySelector(Polymer.veiledElements[i]); | ||
chai.assert.isTrue(getComputedStyle(elt).visibility == 'visible', | ||
'unveiled elements are visible'); | ||
} | ||
chai.assert.equal(document.querySelectorAll('.polymer-veiled').length, 0, | ||
'element classes are cleared after unveiling'); | ||
chai.assert.equal(document.querySelectorAll('.polymer-unveil').length, 0, | ||
'element classes are cleared after unveiling'); | ||
done(); | ||
}); | ||
}, false); | ||
}); | ||
</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
dispay -> display