cms/app-client/app/components/player-component.js
changeset 302 973df1349591
parent 272 97c06607949b
child 306 3fccf43160a7
--- a/cms/app-client/app/components/player-component.js	Mon Sep 26 23:13:15 2016 +0200
+++ b/cms/app-client/app/components/player-component.js	Tue Sep 27 01:40:19 2016 +0200
@@ -19,6 +19,11 @@
         return this.get('player').get('model');
     }),
 
+    didRender: function() {
+        this.textAutoscroll(Ember.$('#' + this.elementId).find('.title'));
+        this.textAutoscroll(Ember.$('#' + this.elementId).find('.author'));
+    },
+
     modelLoaded: Ember.observer('player.model', function() {
         var items = this.get('player').get('items');
         var index = items.indexOf(this.get('player').get('item'));
@@ -64,6 +69,26 @@
         }));
     },
 
+    textAutoscroll: function(jElement) {
+        var text = jElement.find('span');
+        text.stop(true);
+        text.css('text-indent', '0px');
+        if(text.width() > jElement.width()) {
+            var duration = ( ( text.width() - jElement.width() ) * 8 / 100 ) * 1000;
+            function animate() {
+                text.delay(4000)
+                    .animate({
+                        'text-indent': -( text.width() - jElement.width() ) + 'px'
+                    }, duration, 'linear', function() {
+                        text.stop(true);
+                        text.css('text-indent', '0px')
+                        window.setTimeout(function() { animate() }, 1);
+                    });
+            }
+            animate();
+        }
+    },
+
     onUpdate: function() {
         var progress = this.get('popcorn').currentTime();
         var duration = this.get('popcorn').duration();