9 autoscrollElement : '.corpus-app-container', |
9 autoscrollElement : '.corpus-app-container', |
10 previousElement: 0, |
10 previousElement: 0, |
11 autoscroll: true, |
11 autoscroll: true, |
12 timeout: null, |
12 timeout: null, |
13 |
13 |
|
14 hasSections: Ember.computed('player', 'player.transcript', function() { |
|
15 var sections = this.get('player.transcript.sections'); |
|
16 return sections && sections.length > 0; |
|
17 }), |
|
18 |
14 itemObserver: Ember.observer('player.item', function () { |
19 itemObserver: Ember.observer('player.item', function () { |
15 this.set('autoscroll', true); |
20 if ( !(this.get('isDestroyed') || this.get('isDestroying')) ) { |
|
21 this.set('autoscroll', true); |
|
22 } |
16 }), |
23 }), |
17 |
24 |
18 didInsertElement: function() { |
25 didInsertElement: function() { |
19 Ember.$('#' + this.elementId).parent().on('scroll', Ember.run.bind(this, this.onScroll)); |
26 Ember.$('#' + this.elementId).parent().on('scroll', Ember.run.bind(this, this.onScroll)); |
20 }, |
27 }, |
21 |
28 |
22 onScroll: function() { |
29 onScroll: function() { |
23 this.set('autoscroll', false); |
30 if ( !(this.get('isDestroyed') || this.get('isDestroying')) ) { |
24 Ember.$('#' + this.elementId).parent().off('scroll'); |
31 this.set('autoscroll', false); |
|
32 } |
|
33 if(this.elementId) { |
|
34 Ember.$('#' + this.elementId).parent().off('scroll'); |
|
35 } |
25 }, |
36 }, |
26 |
37 |
27 didUpdate: function() { |
38 scroll: Ember.observer('player.progress', function() { |
28 var self = this; |
39 var self = this; |
29 var target = Ember.$('.sentence.active'); |
40 var target = this.$('.sentence.active'); |
30 if(this.get('autoscroll') && target.length && target.attr('data-ember-action') !== this.get('previousElement')) { |
41 if(this.get('autoscroll') && target.length && target.attr('id') !== this.get('previousElement')) { |
31 Ember.$('#' + self.elementId).parent().off('scroll'); |
42 Ember.$('#' + self.elementId).parent().off('scroll'); |
32 Ember.$(this.get('autoscrollElement')).animate({ |
43 Ember.$(this.get('autoscrollElement')).animate({ |
33 scrollTop: target.offset().top + Ember.$(this.get('autoscrollElement')).scrollTop() - Ember.$(this.get('autoscrollElement')).offset().top - 154 |
44 scrollTop: target.offset().top + Ember.$(this.get('autoscrollElement')).scrollTop() - Ember.$(this.get('autoscrollElement')).offset().top - 154 |
34 }, 150, 'swing', function() { |
45 }, 150, 'swing', function() { |
35 setTimeout(function() { |
46 setTimeout(function() { |
36 Ember.$('#' + self.elementId).parent().on('scroll', Ember.run.bind(self, self.onScroll)); |
47 Ember.$('#' + self.elementId).parent().on('scroll', Ember.run.bind(self, self.onScroll)); |
37 }, 100); |
48 }, 100); |
38 }); |
49 }); |
39 this.set('previousElement', target.attr('data-ember-action')); |
50 this.set('previousElement', target.attr('id')); |
40 } |
51 } |
41 }, |
52 }), |
|
53 |
42 |
54 |
43 actions: { |
55 actions: { |
44 |
56 |
45 play: function(progress) { |
57 play: function(progress) { |
46 this.get('player').trigger('progressupdate', progress); |
58 this.get('player').trigger('progressupdate', progress); |
47 this.get('player').set('playing', true); |
59 this.get('player').set('playing', true); |
48 } |
60 } |
49 |
|
50 } |
61 } |
51 |
62 |
52 }); |
63 }); |