react-bootstrap / dom-helpers

tiny, extremely modular, DOM helper library for IE9+
MIT License
403 stars 65 forks source link

suggestion: can offset support the second parameter #105

Closed bplok20010 closed 4 years ago

bplok20010 commented 4 years ago

I don't want to create a package to implement the set offset function. Can dom-helpers support it? e.g.

offset(node, {
top: 100
})

offset(node, {
top: 100,
left: 100
})
taion commented 4 years ago

How would it do this?

bplok20010 commented 4 years ago

@taion offset can only obtain the location information of a node at present, but I also hope to set its location information, such as when dragging.

jQuery has such functions, sometimes it is very convenient.

jquense commented 4 years ago

You can use the css() method to do that. That's what jquery is doing and it's probably not worth the extra code path here.

bplok20010 commented 4 years ago

@jquense The css() method can do it. What I hope is that users don't need to pay attention to the level of DOM, and use offset(e.g offset(node,coords )) to set the coordinates relative to the window, which actually extends the function of offset, but it does bring more code. But they look like a couple :).

bplok20010 commented 4 years ago

I created a npm package to implement.

repo: https://github.com/bplok20010/dom-helpers-extra