我打印出列表的内容,我得到以下输出:
[[...], [...], [...], [...], [...], [...]]
Run Code Online (Sandbox Code Playgroud)
这些奇怪的点是什么?
我使用python 2.7.3
我想在一个页面上移动两个图像.这个布局如下:
|1.1|--2.1--|
|1.2|--2.2--|
|1.3|--2.3--|
|1.4|--2.4--|
Run Code Online (Sandbox Code Playgroud)
因此,图像彼此相邻,以"1"开头的单元属于第一图像,以"2"开头的单元属于第二图像.
当我拖动任何图像时,预期的行为是两个图像都移动,但图像1仅在垂直轴上移动.(因此它保持在左侧,但可能会像图像2一样向上或向下移动.此图像将用作一种标题,并且需要始终在左侧可见,但需要垂直同步对于图像2.),图像2可以沿两个轴移动.
在该示例中,这意味着第一图像的1.1部分将始终与第二图像的2.1部分对齐.
有没有可能支持这个的JS框架?我已经尝试过使用Fabric JS,但是当我在事件处理程序中限制坐标时,它会变得难以置信地变慢.
这段代码是我试过的,它并没有完全按照我的描述进行,这限制了矩形的运动,但它背后的理论是一样的.
canvas.on("object:moving", function() {
var top = movingBox.top;
var bottom = top + movingBox.height;
var left = movingBox.left;
var right = left + movingBox.width;
var topBound = boundingBox.top;
var bottomBound = topBound + boundingBox.height;
var leftBound = boundingBox.left;
var rightBound = leftBound + boundingBox.width;
movingBox.setLeft(Math.min(Math.max(left, leftBound), rightBound - movingBox.width));
movingBox.setTop(Math.min(Math.max(top, topBound), bottomBound - movingBox.height));
});
Run Code Online (Sandbox Code Playgroud)