File tree 5 files changed +24
-24
lines changed
5 files changed +24
-24
lines changed Original file line number Diff line number Diff line change 24
24
< h1 > Dropdowns</ h1 >
25
25
< div class ="mui-panel ">
26
26
< h2 > CSS</ h2 >
27
+
27
28
< div class ="mui-dropdown ">
28
29
< button class ="mui-btn mui-btn--primary " data-mui-toggle ="dropdown ">
29
30
Dropdown
@@ -36,6 +37,7 @@ <h2>CSS</h2>
36
37
< li > < a href ="# "> Option 4</ a > </ li >
37
38
</ ul >
38
39
</ div >
40
+
39
41
< div class ="mui-dropdown ">
40
42
< button class ="mui-btn mui-btn--primary " data-mui-toggle ="dropdown ">
41
43
Dropdown
@@ -48,6 +50,17 @@ <h2>CSS</h2>
48
50
< li > < a href ="# "> Option 4</ a > </ li >
49
51
</ ul >
50
52
</ div >
53
+
54
+ < div class ="mui-dropdown ">
55
+ < a data-mui-toggle ="dropdown "> Click me</ a >
56
+ < ul class ="mui-dropdown__menu ">
57
+ < li > < a href ="# "> Option 1</ a > </ li >
58
+ < li > < a href ="# "> Option 2</ a > </ li >
59
+ < li > < a href ="# "> Option 3</ a > </ li >
60
+ < li > < a href ="# "> Option 4</ a > </ li >
61
+ </ ul >
62
+ </ div >
63
+
51
64
</ div >
52
65
</ div >
53
66
</ body >
Original file line number Diff line number Diff line change @@ -38,14 +38,13 @@ angular.module(moduleName, [])
38
38
rightClass = 'mui-dropdown__menu--right' ,
39
39
isUndef = angular . isUndefined ,
40
40
menuEl ,
41
- buttonEl ;
41
+ buttonEl ,
42
+ marginTop ;
42
43
43
44
// save references
44
45
menuEl = angular . element ( element [ 0 ] . querySelector ( '.' + menuClass ) ) ;
45
46
buttonEl = angular . element ( element [ 0 ] . querySelector ( '.mui-btn' ) ) ;
46
47
47
- menuEl . css ( 'margin-top' , '-3px' ) ;
48
-
49
48
// handle is-open
50
49
if ( ! isUndef ( attrs . open ) ) scope . open = true ;
51
50
Original file line number Diff line number Diff line change @@ -85,13 +85,6 @@ function toggleDropdown(toggleEl) {
85
85
86
86
// method to open dropdown
87
87
function openDropdownFn ( ) {
88
- // position menu element below toggle button
89
- var wrapperRect = wrapperEl . getBoundingClientRect ( ) ,
90
- toggleRect = toggleEl . getBoundingClientRect ( ) ;
91
-
92
- var top = toggleRect . top - wrapperRect . top + toggleRect . height ;
93
- jqLite . css ( menuEl , 'top' , top + 'px' ) ;
94
-
95
88
// add open class to wrapper
96
89
jqLite . addClass ( menuEl , openClass ) ;
97
90
Original file line number Diff line number Diff line change @@ -30,9 +30,9 @@ class Dropdown extends React.Component {
30
30
super ( props ) ;
31
31
32
32
this . state = {
33
- opened : false ,
34
- menuTop : 0
35
- }
33
+ opened : false
34
+ } ;
35
+
36
36
let cb = util . callback ;
37
37
this . selectCB = cb ( this , 'select' ) ;
38
38
this . onClickCB = cb ( this , 'onClick' ) ;
@@ -97,16 +97,7 @@ class Dropdown extends React.Component {
97
97
}
98
98
99
99
open ( ) {
100
- // position menu element below toggle button
101
- let wrapperRect = this . wrapperElRef . getBoundingClientRect ( ) ,
102
- toggleRect ;
103
-
104
- toggleRect = this . buttonElRef . buttonElRef . getBoundingClientRect ( ) ;
105
-
106
- this . setState ( {
107
- opened : true ,
108
- menuTop : toggleRect . top - wrapperRect . top + toggleRect . height
109
- } ) ;
100
+ this . setState ( { opened : true } ) ;
110
101
}
111
102
112
103
close ( ) {
@@ -175,7 +166,6 @@ class Dropdown extends React.Component {
175
166
< ul
176
167
ref = { el => { this . menuElRef = el } }
177
168
className = { cs }
178
- style = { { top : this . state . menuTop } }
179
169
onClick = { this . selectCB }
180
170
>
181
171
{ children }
Original file line number Diff line number Diff line change 94
94
}
95
95
}
96
96
97
+ // margin after mui-btn
98
+ .mui-btn + .mui-dropdown__menu {
99
+ margin-top : -4px ;
100
+ }
101
+
97
102
// right align
98
103
.mui-dropdown__menu--right {
99
104
left : auto ;
You can’t perform that action at this time.
0 commit comments