Scroleable Products Pannel
This commit is contained in:
1 parent
269d25ff93
commit
5b4643d299
5 files changed
+75
-6
No files matched your search
Binary file not shown.
@@ -364,6 +364,18 @@ function newCanvas() {
|
||||
var event = window.event || event; // old IE support
|
||||
let delta = Math.max(-1, Math.min(1, event.wheelDelta || -event.detail));
|
||||
|
||||
/* We try first with panels. */
|
||||
|
||||
let panelContainer = canvas.panelsSpace.getContainer({ x: event.pageX, y: event.pageY });
|
||||
|
||||
if (panelContainer !== undefined && panelContainer.isWheelable === true) {
|
||||
|
||||
panelContainer.eventHandler.raiseEvent("Mouse Wheel", event.wheelDelta);
|
||||
return false; // This instructs the browser not to take the event and scroll the page.
|
||||
}
|
||||
|
||||
/* We try second with floating objects. */
|
||||
|
||||
let floatingObjectIndex = canvas.floatingSpace.floatingLayer.isInside(event.pageX, event.pageY);
|
||||
|
||||
if (floatingObjectIndex > 0) {
|
||||
|
||||
@@ -9,6 +9,7 @@ function newContainer() {
|
||||
parentContainer: undefined,
|
||||
isDraggeable: true,
|
||||
isClickeable: false,
|
||||
isWheelable: false,
|
||||
name: undefined,
|
||||
initialize: initialize
|
||||
};
|
||||
|
||||
+61
-5
@@ -16,6 +16,7 @@
|
||||
container.initialize();
|
||||
|
||||
container.isDraggeable = true;
|
||||
container.isWheelable = true;
|
||||
|
||||
thisObject.container = container;
|
||||
thisObject.container.frame.containerName = "Bot's Products";
|
||||
@@ -23,6 +24,9 @@
|
||||
let isInitialized = false;
|
||||
let productCards = [];
|
||||
|
||||
let visibleProductCards = [];
|
||||
let firstVisibleCard = 1;
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize() {
|
||||
@@ -71,12 +75,12 @@
|
||||
|
||||
productCard.initialize();
|
||||
|
||||
|
||||
/* Container Stuff */
|
||||
|
||||
productCard.container.displacement.parentDisplacement = thisObject.container.displacement;
|
||||
productCard.container.frame.parentFrame = thisObject.container.frame;
|
||||
productCard.container.parentContainer = thisObject.container;
|
||||
productCard.container.isWheelable = true;
|
||||
|
||||
/* Positioning within thisObject Panel */
|
||||
|
||||
@@ -89,6 +93,14 @@
|
||||
|
||||
lastY = lastY + productCard.container.frame.height;
|
||||
|
||||
/* Add to Visible Product Array */
|
||||
|
||||
if (lastY < thisObject.container.frame.height) {
|
||||
|
||||
visibleProductCards.push(productCard);
|
||||
|
||||
}
|
||||
|
||||
/* Add to the Product Array */
|
||||
|
||||
productCards.push(productCard);
|
||||
@@ -96,15 +108,59 @@
|
||||
/* Listen to Status Changes Events */
|
||||
|
||||
productCard.container.eventHandler.listenToEvent('Status Changed', onProductCardStatusChanged);
|
||||
productCard.container.eventHandler.listenToEvent('Mouse Wheel', onMouseWheel);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
thisObject.container.eventHandler.listenToEvent("Mouse Wheel", onMouseWheel);
|
||||
isInitialized = true;
|
||||
|
||||
}
|
||||
|
||||
function onMouseWheel(pDelta) {
|
||||
|
||||
if (pDelta > 0) {
|
||||
pDelta = 1;
|
||||
} else {
|
||||
pDelta = -1;
|
||||
}
|
||||
|
||||
firstVisibleCard = firstVisibleCard + pDelta;
|
||||
|
||||
let availableSlots = visibleProductCards.length;
|
||||
|
||||
if (firstVisibleCard < 1) { firstVisibleCard = 1; }
|
||||
if (firstVisibleCard > (productCards.length - availableSlots + 1)) { firstVisibleCard = productCards.length - availableSlots + 1; }
|
||||
|
||||
visibleProductCards = [];
|
||||
var lastY = 5;
|
||||
|
||||
for (let i = 0; i < productCards.length; i++) {
|
||||
|
||||
if (i + 1 >= firstVisibleCard && i + 1 < firstVisibleCard + availableSlots) {
|
||||
|
||||
let productCard = productCards[i];
|
||||
|
||||
/* Positioning within thisObject Panel */
|
||||
|
||||
let position = {
|
||||
x: 10,
|
||||
y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight()
|
||||
};
|
||||
productCard.container.frame.position.x = position.x;
|
||||
productCard.container.frame.position.y = position.y + lastY;
|
||||
|
||||
lastY = lastY + productCard.container.frame.height;
|
||||
|
||||
/* Add to Visible Product Array */
|
||||
|
||||
visibleProductCards.push(productCard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onProductCardStatusChanged(pProductCard) {
|
||||
|
||||
thisObject.container.eventHandler.raiseEvent('Product Card Status Changed', pProductCard);
|
||||
@@ -139,9 +195,9 @@
|
||||
/* Now we see which is the inner most container that has it */
|
||||
|
||||
|
||||
for (var i = 0; i < productCards.length; i++) {
|
||||
for (var i = 0; i < visibleProductCards.length; i++) {
|
||||
|
||||
container = productCards[i].getContainer(point);
|
||||
container = visibleProductCards[i].getContainer(point);
|
||||
|
||||
if (container !== undefined) {
|
||||
|
||||
@@ -171,8 +227,8 @@
|
||||
|
||||
thisObject.container.frame.draw(false, false, true);
|
||||
|
||||
for (let i = 0; i < productCards.length; i++) {
|
||||
productCards[i].draw();
|
||||
for (let i = 0; i < visibleProductCards.length; i++) {
|
||||
visibleProductCards[i].draw();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ if (CONSOLE_LOG === true) {
|
||||
|
||||
}
|
||||
|
||||
const DEBUG_MODE = true; // This forces the server to read Plotters from the local drive.
|
||||
const DEBUG_MODE = false; // This forces the server to read Plotters from the local drive.
|
||||
|
||||
if (CONSOLE_LOG === true && DEBUG_MODE === true) {
|
||||
|
||||
|
||||
Reference in new issue
Block a user