Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: third_party/polymer/components-chromium/core-animated-pages/transitions/core-transition-pages-extracted.js

Issue 592593002: Inline scripts were extracted from Polymer elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/echo ""/echo/ Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/components-chromium/core-animated-pages/transitions/core-transition-pages-extracted.js
diff --git a/third_party/polymer/components-chromium/core-animated-pages/transitions/core-transition-pages-extracted.js b/third_party/polymer/components-chromium/core-animated-pages/transitions/core-transition-pages-extracted.js
new file mode 100644
index 0000000000000000000000000000000000000000..554f71b96c7b1bfa3b48f6b2e71ee1c027cf2a0e
--- /dev/null
+++ b/third_party/polymer/components-chromium/core-animated-pages/transitions/core-transition-pages-extracted.js
@@ -0,0 +1,123 @@
+
+
+(function () {
+
+// create some basic transition styling data.
+var transitions = CoreStyle.g.transitions = CoreStyle.g.transitions || {};
+transitions.duration = '500ms';
+transitions.heroDelay = '50ms';
+transitions.scaleDelay = '500ms';
+transitions.cascadeFadeDuration = '250ms';
+
+Polymer('core-transition-pages',{
+
+ publish: {
+ /**
+ * This class will be applied to the scope element in the `prepare` function.
+ * It is removed in the `complete` function. Used to activate a set of CSS
+ * rules that need to apply before the transition runs, e.g. a default opacity
+ * or transform for the non-active pages.
+ *
+ * @attribute scopeClass
+ * @type string
+ * @default ''
+ */
+ scopeClass: '',
+
+ /**
+ * This class will be applied to the scope element in the `go` function. It is
+ * remoived in the `complete' function. Generally used to apply a CSS transition
+ * rule only during the transition.
+ *
+ * @attribute activeClass
+ * @type string
+ * @default ''
+ */
+ activeClass: '',
+
+ /**
+ * Specifies which CSS property to look for when it receives a `transitionEnd` event
+ * to determine whether the transition is complete. If not specified, the first
+ * transitionEnd event received will complete the transition.
+ *
+ * @attribute transitionProperty
+ * @type string
+ * @default ''
+ */
+ transitionProperty: ''
+ },
+
+ /**
+ * True if this transition is complete.
+ *
+ * @attribute completed
+ * @type boolean
+ * @default false
+ */
+ completed: false,
+
+ prepare: function(scope, options) {
+ this.boundCompleteFn = this.complete.bind(this, scope);
+ if (this.scopeClass) {
+ scope.classList.add(this.scopeClass);
+ }
+ },
+
+ go: function(scope, options) {
+ this.completed = false;
+ if (this.activeClass) {
+ scope.classList.add(this.activeClass);
+ }
+ scope.addEventListener('transitionend', this.boundCompleteFn, false);
+ },
+
+ setup: function(scope) {
+ if (!scope._pageTransitionStyles) {
+ scope._pageTransitionStyles = {};
+ }
+
+ var name = this.calcStyleName();
+
+ if (!scope._pageTransitionStyles[name]) {
+ this.installStyleInScope(scope, name);
+ scope._pageTransitionStyles[name] = true;
+ }
+ },
+
+ calcStyleName: function() {
+ return this.id || this.localName;
+ },
+
+ installStyleInScope: function(scope, id) {
+ if (!scope.shadowRoot) {
+ scope.createShadowRoot().innerHTML = '<content></content>';
+ }
+ var root = scope.shadowRoot;
+ var scopeStyle = document.createElement('core-style');
+ root.insertBefore(scopeStyle, root.firstChild);
+ scopeStyle.applyRef(id);
+ },
+
+ complete: function(scope, e) {
+ // TODO(yvonne): hack, need to manage completion better
+ if (e.propertyName !== 'box-shadow' && (!this.transitionProperty || e.propertyName.indexOf(this.transitionProperty) !== -1)) {
+ this.completed = true;
+ this.fire('core-transitionend', this, scope);
+ }
+ },
+
+ // TODO(sorvell): ideally we do this in complete.
+ ensureComplete: function(scope) {
+ scope.removeEventListener('transitionend', this.boundCompleteFn, false);
+ if (this.scopeClass) {
+ scope.classList.remove(this.scopeClass);
+ }
+ if (this.activeClass) {
+ scope.classList.remove(this.activeClass);
+ }
+ }
+
+});
+
+})();
+

Powered by Google App Engine
This is Rietveld 408576698