Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] Fix Column Sorting #554

Merged
merged 1 commit into from
Jun 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 18 additions & 30 deletions addon/components/ember-th/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { closest } from '../../-private/utils/element';
import layout from './template';
import { get } from '@ember/object';

const COLUMN_RESIZE = 0;
const COLUMN_REORDERING = 1;
const COLUMN_INACTIVE = 2;
const COLUMN_INACTIVE = 0;
const COLUMN_RESIZING = 1;
const COLUMN_REORDERING = 2;

/**
The table header cell component. This component manages header cell level
Expand Down Expand Up @@ -149,7 +149,6 @@ export default class EmberTh extends Component {
hammer.add(new Hammer.Press({ time: 0 }));

hammer.on('press', this.pressHandler);
hammer.on('pressup', this.pressUpHandler);
hammer.on('panstart', this.panStartHandler);
hammer.on('panmove', this.panMoveHandler);
hammer.on('panend', this.panEndHandler);
Expand All @@ -161,7 +160,6 @@ export default class EmberTh extends Component {
let hammer = this._hammer;

hammer.off('press');
hammer.off('pressup');
hammer.off('panstart');
hammer.off('panmove');
hammer.off('panend');
Expand Down Expand Up @@ -218,41 +216,33 @@ export default class EmberTh extends Component {
}

pressHandler = event => {
let resizeEnabled = this.get('resizeEnabled');
let reorderEnabled = this.get('reorderEnabled');

let [{ clientX, target }] = event.pointers;

if (resizeEnabled && target.classList.contains('et-header-resize-area')) {
this._columnState = COLUMN_RESIZE;
this.get('columnMeta').startResize(clientX);
} else if (reorderEnabled) {
this._columnState = COLUMN_REORDERING;
}
};

pressUpHandler = () => {
if (this._columnState === COLUMN_RESIZE) {
this.get('columnMeta').endResize();
}

next(() => {
this._columnState = COLUMN_INACTIVE;
});
this._originalClientX = clientX;
this._originalTargetWasResize = target.classList.contains('et-header-resize-area');
};

panStartHandler = event => {
let resizeEnabled = this.get('resizeEnabled');
let reorderEnabled = this.get('reorderEnabled');

let [{ clientX }] = event.pointers;

if (this._columnState === COLUMN_REORDERING) {
if (resizeEnabled && this._originalTargetWasResize) {
this._columnState = COLUMN_RESIZING;

this.get('columnMeta').startResize(this._originalClientX);
} else if (reorderEnabled) {
this._columnState = COLUMN_REORDERING;

this.get('columnMeta').startReorder(clientX);
}
};

panMoveHandler = event => {
let [{ clientX }] = event.pointers;

if (this._columnState === COLUMN_RESIZE) {
if (this._columnState === COLUMN_RESIZING) {
this.get('columnMeta').updateResize(clientX);
this._prevClientX = clientX;
} else if (this._columnState === COLUMN_REORDERING) {
Expand All @@ -262,14 +252,12 @@ export default class EmberTh extends Component {
};

panEndHandler = () => {
if (this._columnState === COLUMN_RESIZE) {
if (this._columnState === COLUMN_RESIZING) {
this.get('columnMeta').endResize();
} else if (this._columnState === COLUMN_REORDERING) {
this.get('columnMeta').endReorder();
}

next(() => {
this._columnState = COLUMN_INACTIVE;
});
next(() => (this._columnState = COLUMN_INACTIVE));
};
}
1 change: 1 addition & 0 deletions config/addon-docs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-env node */
'use strict';

// eslint-disable-next-line
const AddonDocsConfig = require('ember-cli-addon-docs/lib/config');

module.exports = class extends AddonDocsConfig {
Expand Down
2 changes: 1 addition & 1 deletion config/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module.exports = function(deployTarget) {
let ENV = {
build: {}
build: {},
// include other plugin configuration that applies to all deploy targets here
};

Expand Down