sindresorhus/devtools-detect: Detect if DevTools is open and its orientation
2020-12-31 12:51:23 Author: github.com(查看原文) 阅读量:330 收藏

Useful for when you want something special to happen when DevTools is open. Like pausing canvas, adding style debug info, etc.

<script src="node_modules/devtools-detect/index.js"></script>
<script type="module">
	// Check if it's open
	console.log('Is DevTools open:', window.devtools.isOpen);

	// Check it's orientation, `undefined` if not open
	console.log('DevTools orientation:', window.devtools.orientation);

	// Get notified when it's opened/closed or orientation changes
	window.addEventListener('devtoolschange', event => {
		console.log('Is DevTools open:', event.detail.isOpen);
		console.log('DevTools orientation:', event.detail.orientation);
	});
</script>

Doesn't work if DevTools is undocked and will show false positive if you toggle any kind of sidebar.


文章来源: https://github.com/sindresorhus/devtools-detect
如有侵权请联系:admin#unsafe.sh