Skip to content

Instantly share code, notes, and snippets.

@OrenBochman
Last active August 22, 2016 07:04
Show Gist options
  • Save OrenBochman/b4d5f3988155453c5bb050f496860b09 to your computer and use it in GitHub Desktop.
Save OrenBochman/b4d5f3988155453c5bb050f496860b09 to your computer and use it in GitHub Desktop.
polymer neon - hero animation
//handle clicks within a certain scope (say a template)
var scope = document.querySelector('template[is="dom-bind"]');
//ripple click target to full screen or at least container scopr
scope._onPolymerClick = function(event) {
this.$.list.sharedElements = {
'ripple': event.target,
'reverse-ripple': event.target
};
//handle click
};
<link rel="import" href="../../neon-shared-element-animatable-behavior.html">
<dom-module id="x-card">
<template>
<style>
:host {
display: block;
overflow: hidden;
}
#placeholder {
opacity: 0;
background-color: grey;
@apply(--layout-fit);
}
</style>
<div id="placeholder"></div>
<div id="container">
<content select="div"></content>
</div>
</template>
</dom-module>
<script>
(function() {
Polymer({
is: 'x-card',
behaviors: [
Polymer.NeonSharedElementAnimatableBehavior
],
properties: {
animationConfig: {
value: function() {
return {
'entry': [{
name: 'ripple-animation',
id: 'ripple',
toPage: this
}, {
name: 'fade-out-animation',
node: this.$.placeholder,
timing: {
delay: 250
}
}, {
name: 'fade-in-animation',
node: this.$.container,
timing: {
delay: 50
}
}],
'exit': [{
name: 'fade-out-animation',
node: this.$.container,
timing: {
duration: 0
}
}, {
name: 'reverse-ripple-animation',
id: 'reverse-ripple',
fromPage: this
}]
};
}
},
sharedElements: {
value: function() {
return {
'ripple': this.$.placeholder,
'reverse-ripple': this.$.placeholder
};
}
}
}
});
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment