Skip to content

Conversation

@munkk
Copy link
Contributor

@munkk munkk commented Jul 30, 2018

No description provided.

import { AppError } from '../infrastructure/error';
import { jobLine } from '../services/job.line';

const OFFSET = 50;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this properties under the scroll.model

const table = this.$table;
const ctrl = new BodyCtrl(model, view, this.root.table, this.root.bag);
const scrollService = new ScrollService(model, this.root.table);
const ctrl = new BodyCtrl(model, view, scrollService, this.root.table, this.root.bag);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instantiate scrollService inside the BodyCtrl

const VELOCITY = 5;

export class ScrollService extends Disposable {
constructor(model, table) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disposable service is not good practice, move all disposables outside of the service and body ctrl

}

doScroll(direction) {
const scrollState = this.model.scroll;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const {scroll} = this.model;

export declare class BodyCtrl {
constructor(model: Model, view: any, table: Table, bag: any);

scrollService: ScrollService;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hide this property

import { Fastdom } from '../services/fastdom';
import { GRID_PREFIX } from '../definition';
import { jobLine } from '../services/job.line';
import { ScrollService } from 'ng2-qgrid/core/scroll/scroll.service';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont use ng2-qgrid in core use relative path

}

canScroll(e) {
const table = this.rect;
Copy link
Collaborator

@klumba12 klumba12 Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just call it rect: const {rect, offset} = this;

export declare class ScrollService {
constructor(model: Model, table: Table);

stop(): void;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add scroll method

e.clientX < (table.right - offset))
}

scroll(e, startCell) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to start


}

doScroll(direction) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to croll

const table = this.rect;
const offset = this.offset;

return !(e.clientY < (table.bottom - offset) &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split this to var defs:
const is... =

const { velocity } = scrollState;
const scrolledToEnd = () => this.isScrolledToEnd(direction);

return () => setInterval(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to use job

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setInterval is located in function, which is already wrapped in Job.
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to tricky, we need to make own interval like a jobLine, or emulate it with job

this.view = view;
this.interval = null;
this.rect = null;
this.body = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use this.markup.body directly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

markup is not available during the ScrollService initialization

listener.on('mousedown', ctrl.onMouseDown.bind(ctrl));
listener.on('mouseup', ctrl.onMouseUp.bind(ctrl));

windowListener.on('resize', () => ctrl.resize());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Investigate if it could be run outsize ng zone

get offset() {
return this.model.scroll().offset;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write unit tests

model.scrollChanged.watch(e => {
if (this.interval) {
const path = this.getPath(this.mouseEvent);
const td = pathFinder.cell(path);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could it be that we do not find td?

const offset = this.offset;

// check if mouse is not in areas which fire scrolling
const mouseNotOnTopSide = e.clientY > (rect.top + offset);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could me make positive booleans? like cursorIsOnTop?

}

start(e, startCell) {
this.mouseEvent = e;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we calculate td here? not in scrollChanged event

this.mouseEvent = e;
this.startCell = startCell;

if (this.interval) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how it could happen on start?

if (direction && !this.interval) {
this.job(() => {
const interval = this.scroll(direction);
this.interval = interval();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we emulate interval with jobs?

const { velocity } = scrollState;
const scrolledToEnd = () => this.isScrolledToEnd(direction);

return () => setInterval(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to tricky, we need to make own interval like a jobLine, or emulate it with job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants