एनिमेटिंग मैं पॉलिमर सीख रहा हूं। मेरे पास एक तत्व है जिसमें div
शामिल है। मैं उस div की ऊंचाई को एनिमेट करना चाहता हूं।पॉलिमर - एक डीआईवी
मेरी-element.html
<dom-module id="my-element">
<template>
<div id="container" style="height:100px; background-color:green; color:white;">
Hello!
</div>
<paper-button on-click="_onTestClick">Expand</paper-button>
</template>
<script>
Polymer({
is: 'my-element',
_onTestClick: function() {
// expand the height of container
}
});
</script>
</dom-module>
मैं तो बढ़ने ऊंचाई एनीमेशन प्रेरणा के लिए here दिखाया प्रयोग किया है: यह करने के लिए की कोशिश में, मैं निम्नलिखित मिल गया है।
Polymer({
is: 'grow-height-animation',
behaviors: [
Polymer.NeonAnimationBehavior
],
configure: function(config) {
var node = config.node;
var rect = node.getBoundingClientRect();
var height = rect.height;
this._effect = new KeyframeEffect(node, [{
height: (height/2) + 'px'
}, {
height: height + 'px'
}], this.timingFromConfig(config));
return this._effect;
}
});
मेरे चुनौती है, मुझे समझ नहीं आता "कंटेनर" की आईडी के साथ div
तत्व के साथ इस एनीमेशन एकीकृत करने के लिए कैसे: तो, मैं मूल रूप से, एक एनीमेशन इस तरह परिभाषित किया गया है। जो कुछ भी मैं देखता हूं वह ऐसा लगता है जैसे यह केवल पॉलिमर तत्वों पर काम करता है। फिर भी, मैं यह समझने की कोशिश कर रहा हूं कि पॉलीमर का उपयोग करके div
को एनिमेट कैसे करें। मैं क्या खो रहा हूँ?
धन्यवाद!