cms/app-client/app/components/transcript-component.js
author Chloe Laisne <chloe.laisne@gmail.com>
Thu, 21 Jul 2016 23:36:50 +0200
changeset 246 5b7ae96768be
parent 245 c9dd78a43b07
child 247 7a5d729992b8
permissions -rw-r--r--
Bsic transcript-component design Autoscroll transcript

import Ember from 'ember';

export default Ember.Component.extend({

    classNames: ['transcript-component'],

    player: Ember.inject.service(),

    autoscroll: true,
    autoscrollElement : Ember.$('.corpus-app-container'),

    itemObserver: Ember.observer('player.item', function () {
        this.set('autoscroll', true);
    }),

    init: function() {
        var self = this;
        this.get('autoscrollElement').bind('scroll', function() {
            self.set('autoscroll', false);
        });

        this._super(...arguments);
    },

    didUpdate: function() {
        if(this.get('autoscroll')) {
            this.get('autoscrollElement').scrollTop((Ember.$('.sentence.active').offset().top + this.get('autoscrollElement').scrollTop()) - this.get('autoscrollElement').offset().top)
        }
    }

});