gpt4 book ai didi

javascript - 使用createjs调整zindex

转载 作者:行者123 更新时间:2023-12-03 08:39:04 25 4
gpt4 key购买 nike

我想在移动时将拖动的项目移动到顶层。

如何确保它不会被拖到另一个对象下。

我可以设置选择移动到排序顺序顶部的“sequenceNumbers”吗?

 //++++++++          Terms to sort            ++++++++++++++++
var xOffset = 100;
for (var a = 0; a < gameData.Terms.length; a++) {
rect = new createjs.Shape();
rect.graphics.beginFill("blue").drawRoundRect(0, 0, 350, 30, 8);
rect.name = a;

var name = new createjs.Text(gameData.Terms[a].Definition, "14pt arial bold", "white");
name.id = gameData.Terms[a].Name;
name.textAlign = "left";
name.y = rect.y + 2;
name.x = rect.x + 4;

var sequenceNumbers = new createjs.Container();

sequenceNumbers.landingSpot = landingSpots[a];
landingSpots[a].sequenceNumber = sequenceNumbers;

sequenceNumbers.addChild(rect, name);
stage.addChild(sequenceNumbers);
sequenceNumbers.x = 300;
sequenceNumbers.y = xOffset;
xOffset += 40;

var startPositionX;
var startPostitionY;

sequenceNumbers.on('mousedown', function (e) {
var posX = e.stageX;
var posY = e.stageY;
startPositionX = e.stageX;
startPositionY = e.stageY;
this.offset = { x: this.x - posX, y: this.y - posY };

});

sequenceNumbers.on("pressmove", function (evt) {
evt.currentTarget.x = evt.stageX;
evt.currentTarget.y = evt.stageY;
var posX = evt.stageX;
var posY = evt.stageY;
this.x = posX + this.offset.x;
this.y = posY + this.offset.y;

});

最佳答案

this.css('z-index','500') 添加到您的 ('mousedown') 调用中。

关于javascript - 使用createjs调整zindex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33109223/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com