cms/app-client/app/components/playlist-component.js
changeset 336 f076ddd29e13
parent 317 e653de66f252
child 338 4a3899b6a7ed
--- a/cms/app-client/app/components/playlist-component.js	Fri Oct 14 19:58:09 2016 +0200
+++ b/cms/app-client/app/components/playlist-component.js	Sat Oct 15 16:15:07 2016 +0530
@@ -20,6 +20,22 @@
         }
     }).on('init'),
 
+    playerItemObserver: Ember.observer('player.item', function() {
+        if(this.$() && this.get('player').get('item')) {
+            var ul = this.$().find('ul');
+            var li = this.$().find('li#' + this.get('player').get('item').replace('.', '\\.').replace('/', '\\/'));
+            if(li.offset().top - ul.offset().top < 0) {
+                ul.animate({
+                    'scrollTop': ul.scrollTop() + li.offset().top - ul.offset().top
+                });
+            } else if(li.offset().top + li.outerHeight() - ul.offset().top > ul.outerHeight()) {
+                ul.animate({
+                    'scrollTop': ul.scrollTop() + li.offset().top  + li.outerHeight() - ul.offset().top  - ul.height()
+                });
+            }
+        }
+    }),
+
     init: function() {
         this._super(...arguments);
     },