简体   繁体   English

Dojo:如何更新dojo.dnd.boxConstrainedMoveable上的约束?

[英]Dojo: How can I update the constraints on a dojo.dnd.boxConstrainedMoveable?

I am using a dojo.dnd.boxConstrainedMoveable within an image cropping widget to allow the user to select a sub-region of the original image. 我在图像裁剪小部件中使用了dojo.dnd.boxConstrainedMoveable,以允许用户选择原始图像的子区域。 Part of this widget allows the user to resize the image. 此小部件的一部分允许用户调整图像的大小。 When this happens, I recalculate the box constraints for the dnd.boxConstrainedMoveable. 发生这种情况时,我将重新计算dnd.boxConstrainedMoveable的框约束。

Below is my code that attempts to update the constraintBox, but doesn't work. 下面是我的代码,试图更新constraintBox,但不起作用。 Is there another method to have the widget recalculate its constraints based on a new constraintBox, as it calculates the constraints when its instantiated? 是否有另一种方法可以让小部件根据新的constraintBox重新计算其约束,因为它在实例化时会计算约束?

    # var dnd = reference to the boxConstrainedMoveable itself
    var mb = dojo.marginBox(cropImage);
    var constraintBox = {t: (mb.h - viewportHeight) * -1,
                         l: (mb.w - viewportWidth) * -1,
                         w: mb.w,
                         h: mb.h};
    this.dnd.constraintBox = constraintBox; # overwrites, but then is reset to original when moved

Use constrainedMoveable instead of boxConstrainedMoveable . 使用constrainedMoveable而不是boxConstrainedMoveable The difference is using a predefined box or a dynamic box. 区别在于使用预定义框或动态框。 constrainedMoveable 受约束的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM