diff -r 1059a7ae018a -r 710a2ae08a74 cms/app-client/app/components/transcript-component.js --- a/cms/app-client/app/components/transcript-component.js Mon Nov 28 23:11:54 2016 +0100 +++ b/cms/app-client/app/components/transcript-component.js Fri Dec 02 00:22:31 2016 +0100 @@ -11,8 +11,15 @@ autoscroll: true, timeout: null, + hasSections: Ember.computed('player', 'player.transcript', function() { + var sections = this.get('player.transcript.sections'); + return sections && sections.length > 0; + }), + itemObserver: Ember.observer('player.item', function () { - this.set('autoscroll', true); + if ( !(this.get('isDestroyed') || this.get('isDestroying')) ) { + this.set('autoscroll', true); + } }), didInsertElement: function() { @@ -20,25 +27,30 @@ }, onScroll: function() { - this.set('autoscroll', false); - Ember.$('#' + this.elementId).parent().off('scroll'); + if ( !(this.get('isDestroyed') || this.get('isDestroying')) ) { + this.set('autoscroll', false); + } + if(this.elementId) { + Ember.$('#' + this.elementId).parent().off('scroll'); + } }, - didUpdate: function() { - var self = this; - var target = Ember.$('.sentence.active'); - if(this.get('autoscroll') && target.length && target.attr('data-ember-action') !== this.get('previousElement')) { - Ember.$('#' + self.elementId).parent().off('scroll'); - Ember.$(this.get('autoscrollElement')).animate({ - scrollTop: target.offset().top + Ember.$(this.get('autoscrollElement')).scrollTop() - Ember.$(this.get('autoscrollElement')).offset().top - 154 - }, 150, 'swing', function() { - setTimeout(function() { - Ember.$('#' + self.elementId).parent().on('scroll', Ember.run.bind(self, self.onScroll)); - }, 100); - }); - this.set('previousElement', target.attr('data-ember-action')); - } - }, + scroll: Ember.observer('player.progress', function() { + var self = this; + var target = this.$('.sentence.active'); + if(this.get('autoscroll') && target.length && target.attr('id') !== this.get('previousElement')) { + Ember.$('#' + self.elementId).parent().off('scroll'); + Ember.$(this.get('autoscrollElement')).animate({ + scrollTop: target.offset().top + Ember.$(this.get('autoscrollElement')).scrollTop() - Ember.$(this.get('autoscrollElement')).offset().top - 154 + }, 150, 'swing', function() { + setTimeout(function() { + Ember.$('#' + self.elementId).parent().on('scroll', Ember.run.bind(self, self.onScroll)); + }, 100); + }); + this.set('previousElement', target.attr('id')); + } + }), + actions: { @@ -46,7 +58,6 @@ this.get('player').trigger('progressupdate', progress); this.get('player').set('playing', true); } - } });