cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <h1>Experiments with HTML5</h1>
		<ul>
			<li><a href="https://www.html5rocks.com/en/tutorials/webcomponents/customelements/">Custom elements</a>. I want a custom-made syntactic html! I want my own tags with behaviour and style!
			<li><a href="https://www.html5rocks.com/en/tutorials/webcomponents/template/">Templates</a>. No more script type="template/x-handlebars-template" hack. Now we have Template html tag.
			<li><a href="https://www.html5rocks.com/en/tutorials/webcomponents/shadowdom/">Shadow DOM</a>. Each tile have its own CSS. And the page CSS does not affect the tiles. See the backgounds!
			<li><a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/">Flexbox</a>. I do not want space between the tiles!
			<li><a href="https://greensock.com/gsap">GSAP</a>. Because I want some animations.
		</ul>

		<template id="tile">
			<style> 
				div {
					border: 3px solid black; 
					width: 256px; height: 256px; 
					background-color: red; }
			</style>
			<div><img src="https://falicov.soluciones3f.com.ar/assets/texture.png" /></div>
		</template>

		<div id="container">
			<s3f-tile back-image="https://falicov.soluciones3f.com.ar/assets/spade.png"></s3f-tile>
			<s3f-tile back-image="https://falicov.soluciones3f.com.ar/assets/heart.png"></s3f-tile>
			<s3f-tile back-image="https://falicov.soluciones3f.com.ar/assets/club.png"></s3f-tile>
			<s3f-tile back-image="https://falicov.soluciones3f.com.ar/assets/diamond.png"></s3f-tile>
		</div>
            
          
!
            
              div { background-color: blue !important; }
			#container { 
				display: flex; flex-flow: row wrap; 
				width: 524px; margin: 0 auto;
			}
            
          
!
            
              var S3fTileProto = Object.create(HTMLElement.prototype);

S3fTileProto.spin = function() {
	// Initiate a spin when it is spinning does not look right.	
	if(this.isSpinning == true) return;
	this.isSpinning = true;

	var $element = $(this.shadowRoot).find("div");
	var $img = $(this.shadowRoot).find("img");
	
	var showFront = function() { $img.attr("src", this.attr("back-image")); }.bind($(this));
	var showBack = function() { $img.attr("src", "https://falicov.soluciones3f.com.ar/assets/texture.png"); };

	TweenLite.set($element, {transformPerspective:500});
	new TimelineLite()
		.fromTo($element, 1, {rotationY: "0deg"}, { rotationY: "90deg", ease: Power1.easeIn, onComplete: showFront })
		.to($element, 1, { rotationY: "180deg", ease: Power1.easeOut })
		.to($element, 1, { rotationY: "270deg", ease: Power1.easeIn, onComplete: showBack })
		.to($element, 1, { rotationY: "360deg", ease: Power1.easeOut, onComplete: function() { this.isSpinning = false }.bind(this) })
		.play();
};

S3fTileProto.createdCallback = function() {
	this.addEventListener('click', this.spin);

	var clone = document.importNode($('#tile')[0].content, true);
	this.createShadowRoot().appendChild(clone);
}

document.registerElement("s3f-tile", { prototype: S3fTileProto });
            
          
!
999px
Loading ..................

Console