1010 */
1111'use strict' ;
1212
13- var setStyle = require ( './setStyle' ) ;
14-
13+ var assign = require ( 'object-assign' ) ;
1514import type { DOMNode } from '../types' ;
1615
1716class Overlay {
@@ -38,14 +37,14 @@ class Overlay {
3837 this . padding . style . borderColor = overlayStyles . padding ;
3938 this . content . style . backgroundColor = overlayStyles . background ;
4039
41- setStyle ( this . node , {
40+ assign ( this . node . style , {
4241 borderColor : overlayStyles . margin ,
4342 pointerEvents : 'none' ,
4443 position : 'fixed' ,
4544 } ) ;
4645
4746 this . tip = doc . createElement ( 'div' ) ;
48- setStyle ( this . tip , {
47+ assign ( this . tip . style , {
4948 border : '1px solid #aaa' ,
5049 backgroundColor : 'rgb(255, 255, 178)' ,
5150 fontFamily : 'sans-serif' ,
@@ -57,13 +56,13 @@ class Overlay {
5756
5857 this . nameSpan = doc . createElement ( 'span' ) ;
5958 this . tip . appendChild ( this . nameSpan ) ;
60- setStyle ( this . nameSpan , {
59+ assign ( this . nameSpan . style , {
6160 color : 'rgb(136, 18, 128)' ,
6261 marginRight : '5px' ,
6362 } ) ;
6463 this . dimSpan = doc . createElement ( 'span' ) ;
6564 this . tip . appendChild ( this . dimSpan ) ;
66- setStyle ( this . dimSpan , {
65+ assign ( this . dimSpan . style , {
6766 color : '#888' ,
6867 } ) ;
6968
@@ -92,12 +91,12 @@ class Overlay {
9291 boxWrap ( dims , 'border' , this . border ) ;
9392 boxWrap ( dims , 'padding' , this . padding ) ;
9493
95- setStyle ( this . content , {
94+ assign ( this . content . style , {
9695 height : box . height - dims . borderTop - dims . borderBottom - dims . paddingTop - dims . paddingBottom + 'px' ,
9796 width : box . width - dims . borderLeft - dims . borderRight - dims . paddingLeft - dims . paddingRight + 'px' ,
9897 } ) ;
9998
100- setStyle ( this . node , {
99+ assign ( this . node . style , {
101100 top : box . top - dims . marginTop + 'px' ,
102101 left : box . left - dims . marginLeft + 'px' ,
103102 } ) ;
@@ -111,7 +110,7 @@ class Overlay {
111110 height : box . height + dims . marginTop + dims . marginBottom ,
112111 width : box . width + dims . marginLeft + dims . marginRight ,
113112 } , this . win ) ;
114- setStyle ( this . tip , tipPos ) ;
113+ assign ( this . tip . style , tipPos ) ;
115114 }
116115}
117116
@@ -138,10 +137,10 @@ function findTipPos(dims, win) {
138137 top += 'px' ;
139138
140139 if ( dims . left < 0 ) {
141- return { top, left : 0 } ;
140+ return { top, left : margin } ;
142141 }
143142 if ( dims . left + 200 > win . innerWidth ) {
144- return { top, right : 0 } ;
143+ return { top, right : margin } ;
145144 }
146145 return { top, left : dims . left + margin + 'px' } ;
147146}
@@ -166,7 +165,7 @@ function getElementDimensions(element) {
166165}
167166
168167function boxWrap ( dims , what , node ) {
169- setStyle ( node , {
168+ assign ( node . style , {
170169 borderTopWidth : dims [ what + 'Top' ] + 'px' ,
171170 borderLeftWidth : dims [ what + 'Left' ] + 'px' ,
172171 borderRightWidth : dims [ what + 'Right' ] + 'px' ,
0 commit comments