Skip to content

Commit 95e6efd

Browse files
committed
use full words instead of abbr & use offset instead of client
1 parent e4c3883 commit 95e6efd

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ ReactDOM.render((
237237
<td>stretch</td>
238238
<td>string</td>
239239
<td></td>
240-
<td>Let popup div stretch with trigger element. enums of 'w', 'h'</td>
240+
<td>Let popup div stretch with trigger element. enums of 'width', 'minWidth', 'height', 'minHeight'. (You can also mixed with 'height minWidth')</td>
241241
</tr>
242242
</tbody>
243243
</table>

examples/simple.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ class Test extends React.Component {
161161
Stretch:
162162
<select value={state.stretch} onChange={this.onStretch}>
163163
<option value="">--NONE--</option>
164-
<option value="w">by width</option>
165-
<option value="h">by height</option>
164+
<option value="width">width</option>
165+
<option value="minWidth">minWidth</option>
166+
<option value="height">height</option>
167+
<option value="minHeight">minHeight</option>
166168
</select>
167169
</label>
168170
&nbsp;&nbsp;&nbsp;&nbsp;

src/Popup.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class Popup extends Component {
7474
const $ele = getRootDomNode();
7575
if (!$ele) return;
7676

77-
const height = $ele.clientHeight;
78-
const width = $ele.clientWidth;
77+
const height = $ele.offsetHeight;
78+
const width = $ele.offsetWidth;
7979

8080
if (targetHeight !== height || targetWidth !== width || !stretchChecked) {
8181
this.setState({
@@ -138,10 +138,14 @@ class Popup extends Component {
138138
if (stretch) {
139139
if (stretchChecked) {
140140
// Stretch with target
141-
if (stretch.indexOf('h') !== -1) {
141+
if (stretch.indexOf('height') !== -1) {
142+
sizeStyle.height = targetHeight;
143+
} else if (stretch.indexOf('minHeight') !== -1) {
142144
sizeStyle.minHeight = targetHeight;
143145
}
144-
if (stretch.indexOf('w') !== -1) {
146+
if (stretch.indexOf('width') !== -1) {
147+
sizeStyle.width = targetWidth;
148+
} else if (stretch.indexOf('minWidth') !== -1) {
145149
sizeStyle.minWidth = targetWidth;
146150
}
147151
} else {

tests/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ describe('rc-trigger', function main() {
745745
), div);
746746

747747
it('width', (done) => {
748-
const trigger = createTrigger('w');
748+
const trigger = createTrigger('width');
749749
const domNode = ReactDOM.findDOMNode(trigger);
750750
Simulate.click(domNode);
751751

@@ -757,7 +757,7 @@ describe('rc-trigger', function main() {
757757
});
758758

759759
it('height', (done) => {
760-
const trigger = createTrigger('h');
760+
const trigger = createTrigger('height');
761761
const domNode = ReactDOM.findDOMNode(trigger);
762762
Simulate.click(domNode);
763763

0 commit comments

Comments
 (0)