Sha256: 0d2c4db87db94ea77849ce8dad1ca16899733fc00235760f91f667d2462f71e1

Contents?: true

Size: 975 Bytes

Versions: 3

Compression:

Stored size: 975 Bytes

Contents

import Component from "@ember/component";

let CHECKED_BOTTOM;
let STICK_TO_BOTTOM;

export default Component.extend({
  tagName: "tr",

  classNameBindings: [
    "model.rowClass",
    ":message-row",
    "model.selected:selected"
  ],

  click() {
    this.selectedMessage(this.get("model"));
  },

  willInsertElement() {
    if (CHECKED_BOTTOM) {
      return;
    }

    const $topPanel = Em.$("#top-panel");

    const scrollTop = $topPanel.scrollTop();
    const height = $topPanel.height();
    const scrollHeight = $topPanel[0].scrollHeight;

    STICK_TO_BOTTOM = scrollHeight - 20 < height + scrollTop;
    CHECKED_BOTTOM = true;
  },

  didInsertElement() {
    const $topPanel = Em.$("#top-panel");
    Em.run.next(() => {
      CHECKED_BOTTOM = false;

      if (STICK_TO_BOTTOM) {
        STICK_TO_BOTTOM = false;
        $topPanel.scrollTop($topPanel[0].scrollHeight - $topPanel.height());
      }
    });
  }
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
logster-1.3.4 client-app/app/components/message-row.js
logster-1.3.3 client-app/app/components/message-row.js
logster-1.3.2 client-app/app/components/message-row.js