Giter Club home page Giter Club logo

Comments (7)

gorkys avatar gorkys commented on May 18, 2024

windowresize事件,只会重新获取父元素的大小。
不知道你所说的组件显示异常体现在什么方面?

from vue-draggable-resizable-gorkys.

Ansel avatar Ansel commented on May 18, 2024

windowresize事件,只会重新获取父元素的大小。
不知道你所说的组件显示异常体现在什么方面?

最终会出现那种,外部props传入的maxWidth是100,但是组件计算出来的computedWidth是150的这种情况,同样的其他props传入值也会和组件计算出来的不一样~~
如果props传入了maxWidth是100的话,表示组件不管怎么操作最终宽度不应该超过100的吧,但实际上computedWidth却没有受这个maxWidth的限制,计算出了超出maxWidth的数值。

from vue-draggable-resizable-gorkys.

gorkys avatar gorkys commented on May 18, 2024

在什么情况下会出现组件计算出来的computedWidth是150呢?
目前测试,在maxWidth为100的时候,
除非手动传值为出现超出的情况(console中会抛出警告,另,操作组件缩放功能时会还原到规定的最大值),
直接操作组件(通过按钮动态累加也不会超过maxWidth)的缩放功能问题不会出现。
关于限制是在calcResizeLimits方法中进行的。

from vue-draggable-resizable-gorkys.

Ansel avatar Ansel commented on May 18, 2024

在什么情况下会出现组件计算出来的computedWidth是150呢?
目前测试,在maxWidth为100的时候,
除非手动传值为出现超出的情况(console中会抛出警告,另,操作组件缩放功能时会还原到规定的最大值),
直接操作组件(通过按钮动态累加也不会超过maxWidth)的缩放功能问题不会出现。

外部组件自己响应了resize然后重新计算出来了width、height、x、y、maxWidth、maxHeight、minWidth、minHeight等属性,而vdr自己会watch w的值,并且同时监听了resize事件,在窗口大小改变比较快的时候,就有可能出现vdr自己计算的数据和外部计算的数据不一致,而vdr采用了自己计算的结果,并未对自己计算结果进行maxWidth、maxHeight等控制。
再次操作时确实会还原到props传的最大值,但毕竟是存在了显示位置有误的情况,显示异常的情况确实会存在。
所以,是不是考虑对计算属性style中的内容进行当前计算结果和最小值、最大值的比较并修正结果呢?

比如如下这种:
style () {
return {
transform: translate(${this.left}px, ${this.top}px),
width: this.computedWidth < this.minWidth ? this.minWidth : this.computedWidth > this.maxWidth ? this.maxWidth : this.computedWidth,
height: this.computedHeight < this.minHeight ? this.minHeight : this.computedHeight > this.maxHeight ? this.maxHeight : this.computedHeight,

zIndex: this.zIndex,
...(this.dragging && this.disableUserSelect ? userSelectNone : userSelectAuto)
}
}

如果props中传递了x和y,这个时候是否应该采用props中的值呢?是基于什么样的原因采用了自己计算的left和top值呢?

from vue-draggable-resizable-gorkys.

gorkys avatar gorkys commented on May 18, 2024

实在抱歉,没法复现所述问题,我想你可以去原组件仓库提交一个issues。或者加入交流群讨论一下。
另,如果传入了X,Y,事实上组件是采用了传入的值,只是将它们分别赋给了lefttop,在逻辑上它们是一样的,只是命名上不一样罢了。因为会做很多计算,而vue的规范中好像是有提到不要直接对props传入的值进行操作。
当然,这些只是我的理解,组件并不完全是由我开发出来的,我只是增加了原作者不会去加入的一些我觉得需要的功能。

from vue-draggable-resizable-gorkys.

Ansel avatar Ansel commented on May 18, 2024

实在抱歉,没法复现所述问题,我想你可以去原组件仓库提交一个issues。或者加入交流群讨论一下。
另,如果传入了X,Y,事实上组件是采用了传入的值,只是将它们分别赋给了lefttop,在逻辑上它们是一样的,只是命名上不一样罢了。因为会做很多计算,而vue的规范中好像是有提到不要直接对props传入的值进行操作。
当然,这些只是我的理解,组件并不完全是由我开发出来的,我只是增加了原作者不会去加入的一些我觉得需要的功能。

多谢耐心解答~~

from vue-draggable-resizable-gorkys.

XiaoDan12202 avatar XiaoDan12202 commented on May 18, 2024

实在抱歉,没法复现所述问题,我想你可以去原组件仓库提交一个issues。或者加入交流群讨论一下。
另,如果传入了X,Y,事实上组件是采用了传入的值,只是将它们分别赋给了lefttop,在逻辑上它们是一样的,只是命名上不一样罢了。因为会做很多计算,而vue的规范中好像是有提到不要直接对props传入的值进行操作。
当然,这些只是我的理解,组件并不完全是由我开发出来的,我只是增加了原作者不会去加入的一些我觉得需要的功能。

多谢耐心解答~~

解决了吗?我现在也是这种情况,我只能自己计算好再覆盖它的style,请问有什么更好的办法吗?

from vue-draggable-resizable-gorkys.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.