Issue: I am successfully dragged scroll bar thumb but whenever I dragged Scroll bar thumb it drags the diagram as well and due to this node get vibrate.
Node Screenshot:
Scroll Bar code:
$(go.Panel, “Vertical”,
{
width: 13,
row: 1, column: 1,
alignment: go.Spot.Right, alignmentFocus: go.Spot.Left,
margin: new go.Margin(1, 1, 1, 1),
},
new go.Binding("visible", "ruledetails", setScrollBarVisible),
$("Button",
{
name: "UP", click: (e, obj) => {
scroll(obj.part, -1);
}, width: 20, height: 20
},
$(go.Shape, "TriangleUp", { width: 6, height: 10 })
),
$(go.Panel, "Auto",
{
name: "SCROLLBAR",
width: 13,
height: 213 //213
},
$(go.Shape, { fill: "lightgray" }), // Background for scrollbar
$(go.Shape, "Rectangle",
{
name: "SCROLLBAR_THUMB",
fill: "gray",
width: 11,
alignment: go.Spot.Top,
alignmentFocus: go.Spot.Top,
mouseEnter: (e: any, obj: any) => thumbClicked(obj),
},
new go.Binding("height","",setThumbHeight)
)
),
$("Button",
{
name: "DOWN", click: (e, obj) => {
scroll(obj.part, 1);
}, width: 20, height: 20
},
$(go.Shape, "TriangleDown", { width: 6, height: 10 })
)
)
Code used for dragging thumb:
this.myDiagram.addDiagramListener(“ViewportBoundsChanged”, function (e) {
Diagram.toolManager.panningTool.isEnabled = false;
var diagram = e.diagram;
diagram.toolManager.panningTool.isEnabled = false;
const d = diagram.lastInput;
const currentViewportPosition = e.diagram.viewportBounds.position;
if (d.left) {
const part = diagram.findPartAt(d.documentPoint, true);
var node = part?.findObject(“MainNode”);
var thumb = part?.findObject("SCROLLBAR_THUMB");
if (thumb) {
var thumbPosition = thumb.getDocumentPoint(go.Spot.Center);
console.log("Thumb Position: " + thumbPosition.toString());
var mousePt = Diagram.lastInput.documentPoint;
console.log("Mouse Position: " + mousePt.toString());
if (mousePt.y > thumbPosition.y || mousePt.y < thumbPosition.y) {
diagram.toolManager.draggingTool.isEnabled = false;
Diagram.toolManager.panningTool.isEnabled = false;
diagram.toolManager.panningTool.isEnabled = false;
if (mousePt.y > thumbPosition.y) {
scroll(part, 1 * scrollSpeedMultiplier);
} else if (mousePt.y < thumbPosition.y) {
scroll(part, -1 * scrollSpeedMultiplier);
console.log("Thumb scrolled up");
}
previousViewportPosition = currentViewportPosition; // Update the previous position
}
if (node instanceof go.Node) {
// @ts-ignore
node.movable = true;
}
diagram.toolManager.draggingTool.isEnabled = true;
Diagram.toolManager.panningTool.isEnabled = false;
diagram.toolManager.panningTool.isEnabled = false;
}
}
},
);