Skip to content

Commit 9cca14c

Browse files
fixed sort, resize & scroll
1 parent 009df78 commit 9cca14c

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

source/js/PivotView.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,9 @@ PivotView.prototype.colorNameToRGB = function (name) {
483483
};
484484

485485
/**
486+
* Size updater for LPT.
487+
* Do not affect scroll positions in this function.
488+
*
486489
* @param container
487490
*/
488491
PivotView.prototype.recalculateSizes = function (container) {
@@ -564,7 +567,6 @@ PivotView.prototype.recalculateSizes = function (container) {
564567
console.warn("No _primaryRows property in container, cell sizes won't be fixed.");
565568
}
566569

567-
_.saveScrollPosition();
568570
container.parentNode.removeChild(container); // detach
569571

570572
topHeader.style.marginLeft = headerW + "px";
@@ -620,7 +622,6 @@ PivotView.prototype.recalculateSizes = function (container) {
620622
}
621623

622624
containerParent.appendChild(container); // attach
623-
_.restoreScrollPosition();
624625

625626
/*
626627
* View in (listing) may have another size after attaching just because of applying
@@ -749,16 +750,16 @@ PivotView.prototype.renderRawData = function (data) {
749750
}
750751
};
751752

752-
var getMouseXY = function (e) {
753-
var element = e.target || e.srcElement, offsetX = 0, offsetY = 0;
754-
if (element.offsetParent) {
755-
do {
756-
offsetX += element.offsetLeft;
757-
offsetY += element.offsetTop;
758-
} while ((element = element.offsetParent));
759-
}
760-
return { x: e.pageX - offsetX, y: e.pageY - offsetY };
761-
};
753+
//var getMouseXY = function (e) {
754+
// var element = e.target || e.srcElement, offsetX = 0, offsetY = 0;
755+
// if (element.offsetParent) {
756+
// do {
757+
// offsetX += element.offsetLeft;
758+
// offsetY += element.offsetTop;
759+
// } while ((element = element.offsetParent));
760+
// }
761+
// return { x: e.pageX - offsetX, y: e.pageY - offsetY };
762+
//};
762763

763764
var bindResize = function (element, column) {
764765

@@ -779,18 +780,19 @@ PivotView.prototype.renderRawData = function (data) {
779780
}
780781

781782
el.addEventListener("mousedown", function (e) {
782-
var cursorX = getMouseXY(e).x;
783-
if (cursorX < el.offsetWidth - 5 && cursorX > 5) {
784-
return;
785-
}
783+
//var cursorX = getMouseXY(e).x;
784+
//if (cursorX < el.offsetWidth - 5 && cursorX > 5) {
785+
// return;
786+
//}
787+
if ((e.target || e.srcElement) !== el) return;
786788
e.cancelBubble = true;
787789
e.preventDefault();
788790
_RESIZING = true;
789791
_RESIZING_ELEMENT = el;
790792
_RESIZING_ELEMENT_BASE_WIDTH = el.offsetWidth;
791793
_RESIZING_ELEMENT_BASE_X = e.pageX;
792794
_RESIZING_COLUMN_INDEX = colIndex;
793-
el._CANCEL_CLICK_EVENT = true;
795+
//el._CANCEL_CLICK_EVENT = true;
794796
});
795797

796798
el.addEventListener("mouseup", function (e) {
@@ -806,7 +808,7 @@ PivotView.prototype.renderRawData = function (data) {
806808
_.recalculateSizes(container);
807809
_.restoreScrollPosition();
808810
setTimeout(function () {
809-
_RESIZING_ELEMENT._CANCEL_CLICK_EVENT = false;
811+
//_RESIZING_ELEMENT._CANCEL_CLICK_EVENT = false;
810812
_RESIZING_ELEMENT = null;
811813
}, 1);
812814
});
@@ -890,12 +892,12 @@ PivotView.prototype.renderRawData = function (data) {
890892
if (!vertical && y === yTo - 1 - ATTACH_TOTALS && !th["_hasSortingListener"]) {
891893
th["_hasSortingListener"] = false; // why false?
892894
//console.log("Click bind to", th);
893-
th.addEventListener(CLICK_EVENT, (function (i, th) {
895+
th.addEventListener(CLICK_EVENT, (function (i) {
894896
return function () {
895-
if (th._CANCEL_CLICK_EVENT) return;
897+
//if (th._CANCEL_CLICK_EVENT) return;
896898
_._columnClickHandler.call(_, i);
897899
};
898-
})(x - info.leftHeaderColumnsNumber, th));
900+
})(x - info.leftHeaderColumnsNumber));
899901
th.className = (th.className || "") + " lpt-clickable";
900902
}
901903
if (!vertical && y === yTo - 1) {

0 commit comments

Comments
 (0)