Git Product home page Git Product logo

dom-align's People

Contributors

afc163 avatar benjycui avatar dependabot[bot] avatar gavinxgu avatar hewenguang avatar popomore avatar raohai avatar roopen219 avatar tinyfind avatar yiminghe avatar zombiej avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dom-align's Issues

css-vendor does not support IE8

css-vendor will call window.getComputedStyle without checking if it is defined. The latest version import css-vender make rc-align crash in IE8

Cannot read property '1' of undefined

It occurred in using rc-color-picker accidently.
Error tracker positioned the error source code:
He.prototype.__iterate = function(e, t) { var n = this , r = 0; return this._root && this._root.iterate((function(t) { return r++, e(t[1], t[0], n) } ), t), r }
Need Help.

computedStyle.getPropertyValue(undefined) Error

image

add && 'name' judgment

//   /dom-align/src/utils.js

function _getComputedStyle(elem, name, cs) {
  var computedStyle = cs;
  var val = '';
  var d = getDocument(elem);
  computedStyle = computedStyle || d.defaultView.getComputedStyle(elem, null); // https://github.com/kissyteam/kissy/issues/61

  if (computedStyle && name) {
    val = computedStyle.getPropertyValue(name) || computedStyle[name];
  }

  return val;
}

alwaysByViewport 是否可以支持offset配置

页面底部有一定区域增加了fixed布局的浮层
使用rc-dropdown、rc-trigger等引用dom-align调整弹框对齐位置的组件时,会出现下拉浮层被fixed层遮挡
希望可以通过某些参数支持alwaysByViewport + offset来调整overflow的判断

即希望可以支持设置距离可视窗口一定距离时,做overflow判断,以调整弹出菜单的位置

当 position (非 static属性) 和 overflow (非 visible属性)不在 同一个元素上时,可视区域 计算会遗漏

前置条件:

dom 结构如下图

image

实际结果:

image

image

sourceNode 获取到的 offsetParent 是 上图中 ”position:fixed“ 的元素,这样的话,就直接跳过了 ”overflow:auto“ 的元素参与 可视区域计算的过程,又因为 ”position:fixed“ 的元素 的overflow 属性 为 "visible" ,他之上的元素一直到 body都是 ”visible“ 属性,导致最终的可视区域 就变为了 body

image

预期结果:

image

getComputedStyleX is not a function

I'm unit testing a component of mine that uses antd dropdown.
I get this error when trying to use enzyme to mount the component and then simulate a click on that drop down.

The above error occurred in the <Align> component:
    in Align (created by Popup)
    in AnimateChild (created by Animate)
    in Animate (created by Popup)
    in div (created by Popup)
    in Popup (created by Trigger)
    in Portal (created by Trigger)
    in Trigger (created by Dropdown)
    in Dropdown (created by Dropdown)
 TypeError: getComputedStyleX is not a function
          at getWH (node_modules/dom-align/lib/utils.js:434:23)
          at HTMLAnchorElement.<anonymous> (node_modules/dom-align/lib/utils.js:486:19)
          at swap (node_modules/dom-align/lib/utils.js:359:12)
          at getWHIgnoreDisplay (node_modules/dom-align/lib/utils.js:485:5)
          at Object.domUtils.(anonymous function) [as outerWidth] (node_modules/dom- 
   align/lib/utils.js:495:18)
          at getRegion (node_modules/dom-align/lib/getRegion.js:19:28)
          at alignElement (node_modules/dom-align/lib/align/alignElement.js:34:50)
          at Align._this.forceAlign (node_modules/rc-align/lib/Align.js:76:47)
          at Align.componentDidMount (node_modules/rc-align/lib/Align.js:91:10)
         at commitLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:14362:22)

I definitely do have a window defined.


        console.log(".....", window.getComputedStyle);
        let wrapper = mount(<UserMenu />);
        wrapper.find(Dropdown).simulate('click')

Setting OverflowX is not adjusting source onto screen

See demo here:

http://requirebin.com/?gist=1406e9992ca56949d224903c2f87c11a

My understanding of setting overflow: {adjustX: true} is that if the source is positioned offscreen it should be adjusted back onto the screen

As seen in the provided example this does not seem to be happening.

It seems like this was a regression caused by this commit: aaac734 . Specifically

newOverflowCfg.adjustX = overflow.adjustX &&
      isFailX(elFuturePos, elRegion, realXRegion);

Should be

newOverflowCfg.adjustX = overflow.adjustX &&
      isFailX(elFuturePos, elRegion, visibleRect);

sourceNode在X轴或者Y轴均无法完全显示,如果允许调整位置({adjustX: true, adjustY: true}),但单个方向能够调整,domAlign返回值有误

代码:https://github.com/MrErHu/dom-align-bugfix-demo(url: http://localhost:3000/bugfix)
原始状态如下:
image

source node:

  • width: 100
  • height: 40:
  • marginTop: 30

taget node:

  • width: 100
  • height: 40
  • left: 0
  • right: 0

当配置:

{
    points: ['bc', 'tc'],
    offset: [0, -10],
    targetOffset: [0, 0],
    overflow: {
        adjustX: true,
        adjustY: true,
    }
}

理论上Y轴无法显示,source node的points应该改变为 ['tc', 'bc']`,对应的offset: [0, 10]。
但是实际情况是:
image

Menu有问题

使用最新的SiderMenu后出现这个问题, 源码例子测试没有这个问题, 所以不知道怎么处理, 请教一下!
Menu Collapsed 之后二级菜单没有变成弹出框, 而是保持原来的下拉框, 是什么情况呢

image

points is undefined.

getElFuturePos.js:4 Uncaught TypeError: Cannot read property '1' of undefined.

ReferenceError: getComputedStyle is not defined

After the 1.8.1 update our tests which use jsdom fail with the error:

ReferenceError: getComputedStyle is not defined
    at getVisibleRectForElement (/home/developer/workspace/main/pvc-core/webui/node_modules/dom-align/lib/getVisibleRectForElement.js:83:19)
    at isOutOfVisibleRect (/home/developer/workspace/main/pvc-core/webui/node_modules/dom-align/lib/align/alignElement.js:26:63)
    at alignElement (/home/developer/workspace/main/pvc-core/webui/node_modules/dom-align/lib/align/alignElement.js:36:34)
    at Align._this.forceAlign (/home/developer/workspace/main/pvc-core/webui/node_modules/rc-align/lib/Align.js:88:47)
    at Align.componentDidMount (/home/developer/workspace/main/pvc-core/webui/node_modules/rc-align/lib/Align.js:107:12)
    at /home/developer/workspace/main/pvc-core/webui/node_modules/react-dom/lib/ReactCompositeComponent.js:262:25
    at measureLifeCyclePerf (/home/developer/workspace/main/pvc-core/webui/node_modules/react-dom/lib/ReactCompositeComponent.js:73:12)
    at /home/developer/workspace/main/pvc-core/webui/node_modules/react-dom/lib/ReactCompositeComponent.js:261:11
    at CallbackQueue.notifyAll (/home/developer/workspace/main/pvc-core/webui/node_modules/react-dom/lib/CallbackQueue.js:74:22)
    at ReactReconcileTransaction.close (/home/developer/workspace/main/pvc-core/webui/node_modules/react-dom/lib/ReactReconcileTransaction.js:78:26)

Is their a workaround for this?

Usage With Elements Within Shadow Dom

I am using the antd library for my UI (located within a shadow dom in an Google Chrome Extension) and have been experiencing issues when using the Popover component. I've traced the error back to the use of this library when trying to work with document fragments, which breaks the flow.

Any advice on this?

是否有比较合理的方式可以在外层判断是否经过了adjust?

您好,我的问题是,如果dom-align后对target node进行了调整,在外面怎么才能确定确实经过了adjust呢?目前domAlign方法的返回值里有point、offset和targetoffset,我想的是可以根据这几个值是否经过flipOffset处理过来判断是否经过了adjust,但这样的方式感觉不够直观,请问是否有其他方式来进行这种判断呢?
或者把fail也返回?

Source node without an explicit "left"/"top" would not align correctly

I agree the source node is good to have an initial "left/top" set (i.e "-9999px"), to shown out of screen before we calculated the actual position. However, not all developers doing good things.

Debugging into the source, the issue happens in utils.setOffset, current is always 0 if the initial "left/top" are not set.

...
for (key in offset) {
  current = parseFloat(css(elem, key)) || 0;
  ret[key] = current + offset[key] - old[key];
}
...

BTW, I'm from China, to keep consistent with your repo style, I'm using English instead. And this tool is cool 😋

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.