瀏覽代碼

Use ResizeObserver to fix issues with leaving full screen in Chrome (fixes #897).

For some reason, Chrome returns incorrect element sizes when the
`fullscreenchange` fires after leaving full screen when using the Video.js
plugin. It seems the event fires before the element is properly sized. Using a
ResizeObserver on the container element fixes this issue.
pull/918/head
Matthew Petroff 4 年之前
父節點
當前提交
44e878f307
共有 1 個檔案被更改,包括 14 行新增4 行删除
  1. +14
    -4
      src/js/pannellum.js

+ 14
- 4
src/js/pannellum.js 查看文件

@@ -69,6 +69,7 @@ var config,
specifiedPhotoSphereExcludes = [],
update = false, // Should we update when still to render dynamic content
eps = 1e-6,
resizeObserver,
hotspotsCreated = false,
destroyed = false;

@@ -493,8 +494,13 @@ function onImageLoad() {
container.addEventListener('webkitfullscreenchange', onFullScreenChange, false);
container.addEventListener('msfullscreenchange', onFullScreenChange, false);
container.addEventListener('fullscreenchange', onFullScreenChange, false);
window.addEventListener('resize', onDocumentResize, false);
window.addEventListener('orientationchange', onDocumentResize, false);
if (typeof ResizeObserver === 'function') {
resizeObserver = new ResizeObserver(onDocumentResize);
resizeObserver.observe(container);
} else {
window.addEventListener('resize', onDocumentResize, false);
window.addEventListener('orientationchange', onDocumentResize, false);
}
if (!config.disableKeyboardCtrl) {
container.addEventListener('keydown', onDocumentKeyPress, false);
container.addEventListener('keyup', onDocumentKeyUp, false);
@@ -3244,8 +3250,12 @@ this.destroy = function() {
container.removeEventListener('webkitfullscreenchange', onFullScreenChange, false);
container.removeEventListener('msfullscreenchange', onFullScreenChange, false);
container.removeEventListener('fullscreenchange', onFullScreenChange, false);
window.removeEventListener('resize', onDocumentResize, false);
window.removeEventListener('orientationchange', onDocumentResize, false);
if (resizeObserver) {
resizeObserver.disconnect();
} else {
window.removeEventListener('resize', onDocumentResize, false);
window.removeEventListener('orientationchange', onDocumentResize, false);
}
container.removeEventListener('keydown', onDocumentKeyPress, false);
container.removeEventListener('keyup', onDocumentKeyUp, false);
container.removeEventListener('blur', clearKeys, false);


Loading…
取消
儲存