| 
									
										
										
										
											2018-12-06 16:28:45 +08:00
										 |  |  | import {root, inBrowser} from './env' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-23 10:57:58 +08:00
										 |  |  | /* istanbul ignore file */ | 
					
						
							| 
									
										
										
										
											2018-03-26 16:04:04 +08:00
										 |  |  | export const render = (function(global) { | 
					
						
							| 
									
										
										
										
											2018-12-06 16:28:45 +08:00
										 |  |  |   // for ssr
 | 
					
						
							|  |  |  |   if (!inBrowser) { | 
					
						
							|  |  |  |     return function(content, left, top) { | 
					
						
							|  |  |  |       content.style.marginLeft = left ? `${-left}px` : '' | 
					
						
							|  |  |  |       content.style.marginTop = top ? `${-top}px` : '' | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-03-26 16:04:04 +08:00
										 |  |  |   const docStyle = document.documentElement.style | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   let engine | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (global.opera && Object.prototype.toString.call(opera) === '[object Opera]') { | 
					
						
							|  |  |  |     engine = 'presto' | 
					
						
							|  |  |  |   } else if ('MozAppearance' in docStyle) { | 
					
						
							|  |  |  |     engine = 'gecko' | 
					
						
							|  |  |  |   } else if ('WebkitAppearance' in docStyle) { | 
					
						
							|  |  |  |     engine = 'webkit' | 
					
						
							|  |  |  |   } else if (typeof navigator.cpuClass === 'string') { | 
					
						
							|  |  |  |     engine = 'trident' | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const vendorPrefix = { | 
					
						
							|  |  |  |     trident: 'ms', | 
					
						
							|  |  |  |     gecko: 'Moz', | 
					
						
							|  |  |  |     webkit: 'Webkit', | 
					
						
							|  |  |  |     presto: 'O', | 
					
						
							|  |  |  |   }[engine] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const helperElem = document.createElement('div') | 
					
						
							|  |  |  |   const perspectiveProperty = vendorPrefix + 'Perspective' | 
					
						
							|  |  |  |   const transformProperty = vendorPrefix + 'Transform' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (helperElem.style[perspectiveProperty] !== undefined) { | 
					
						
							| 
									
										
										
										
											2018-12-03 19:43:21 +08:00
										 |  |  |     return function(content, left, top, useNativeDriver = true) { | 
					
						
							|  |  |  |       if (useNativeDriver) { | 
					
						
							|  |  |  |         content.style[transformProperty] = `translate3d(${-left}px,${-top}px,0)` | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         content.style[transformProperty] = `translate(${-left}px,${-top}px)` | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2018-03-26 16:04:04 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |   } else if (helperElem.style[transformProperty] !== undefined) { | 
					
						
							|  |  |  |     return function(content, left, top) { | 
					
						
							| 
									
										
										
										
											2018-12-03 19:43:21 +08:00
										 |  |  |       content.style[transformProperty] = `translate(${-left}px,${-top}px)` | 
					
						
							| 
									
										
										
										
											2018-03-26 16:04:04 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |   } else { | 
					
						
							|  |  |  |     return function(content, left, top) { | 
					
						
							|  |  |  |       content.style.marginLeft = left ? `${-left}px` : '' | 
					
						
							|  |  |  |       content.style.marginTop = top ? `${-top}px` : '' | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-12-06 16:28:45 +08:00
										 |  |  | })(root) |