| 124 | } |
| 125 | |
| 126 | function assembleTransform(x: number, y: number, toString?: boolean) { |
| 127 | // If using float on style, the final width of the dom might |
| 128 | // keep changing slightly while mouse move. So `toFixed(0)` them. |
| 129 | const x0 = x.toFixed(0) + 'px'; |
| 130 | const y0 = y.toFixed(0) + 'px'; |
| 131 | // not support transform, use `left` and `top` instead. |
| 132 | if (!env.transformSupported) { |
| 133 | return toString |
| 134 | ? `top:${y0};left:${x0};` |
| 135 | : [['top', y0], ['left', x0]]; |
| 136 | } |
| 137 | // support transform |
| 138 | const is3d = env.transform3dSupported; |
| 139 | const translate = `translate${is3d ? '3d' : ''}(${x0},${y0}${is3d ? ',0' : ''})`; |
| 140 | return toString |
| 141 | ? 'top:0;left:0;' + CSS_TRANSFORM_VENDOR + ':' + translate + ';' |
| 142 | : [['top', 0], ['left', 0], [TRANSFORM_VENDOR, translate]]; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * @param {Object} textStyle |