Pan: eventhandler unbinding. Fixed 'reset zoom' in popup
This commit is contained in:
parent
2bd83fbc01
commit
7036799e9f
@ -1,9 +1,10 @@
|
|||||||
// Set prod to true when releasing
|
// Set prod to true when releasing
|
||||||
_prod = true;
|
// _prod = true;
|
||||||
// _prod = false;
|
_prod = false;
|
||||||
|
|
||||||
Debug = {
|
Debug = {
|
||||||
debug: true,
|
init: true,
|
||||||
|
debug: false,
|
||||||
keyboard: true,
|
keyboard: true,
|
||||||
debugResizer: true,
|
debugResizer: true,
|
||||||
debugArDetect: true,
|
debugArDetect: true,
|
||||||
|
@ -255,7 +255,11 @@ class CommsServer {
|
|||||||
|
|
||||||
if (message.cmd === 'announce-zoom') {
|
if (message.cmd === 'announce-zoom') {
|
||||||
// forward off to the popup, no use for this here
|
// forward off to the popup, no use for this here
|
||||||
this.popupPort.postMessage({cmd: 'set-current-zoom', zoom: message.zoom});
|
try {
|
||||||
|
this.popupPort.postMessage({cmd: 'set-current-zoom', zoom: message.zoom});
|
||||||
|
} catch (e) {
|
||||||
|
// can't forward stuff to popup if it isn't open
|
||||||
|
}
|
||||||
} else if (message.cmd === 'get-current-zoom') {
|
} else if (message.cmd === 'get-current-zoom') {
|
||||||
this.sendToActive(message);
|
this.sendToActive(message);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,9 @@ class PlayerData {
|
|||||||
return ( window.innerHeight == window.screen.height && window.innerWidth == window.screen.width);
|
return ( window.innerHeight == window.screen.height && window.innerWidth == window.screen.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panListener(event) {
|
||||||
|
this.panHandler(event);
|
||||||
|
}
|
||||||
|
|
||||||
start(){
|
start(){
|
||||||
this.startChangeDetection();
|
this.startChangeDetection();
|
||||||
@ -57,6 +59,7 @@ class PlayerData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
|
this.element.removeEventListener('mousemove', this.panListener);
|
||||||
this.stopChangeDetection();
|
this.stopChangeDetection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +159,7 @@ class PlayerData {
|
|||||||
|
|
||||||
if(this.element) {
|
if(this.element) {
|
||||||
const ths = this;
|
const ths = this;
|
||||||
this.element.removeEventListener('mousemove', (event) => ths.panHandler(event));
|
this.element.removeEventListener('mousemove', this.panListener);
|
||||||
}
|
}
|
||||||
this.element = undefined;
|
this.element = undefined;
|
||||||
this.dimensions = undefined;
|
this.dimensions = undefined;
|
||||||
@ -224,10 +227,10 @@ class PlayerData {
|
|||||||
}
|
}
|
||||||
const ths = this;
|
const ths = this;
|
||||||
if(this.element) {
|
if(this.element) {
|
||||||
this.element.removeEventListener('mousemove', (event) => ths.panHandler(event));
|
this.element.removeEventListener('mousemove', (event) => ths.panListener);
|
||||||
}
|
}
|
||||||
this.element = element;
|
this.element = element;
|
||||||
this.element.addEventListener('mousemove', (event) => ths.panHandler(event));
|
this.element.addEventListener('mousemove', ths.panListener);
|
||||||
} else {
|
} else {
|
||||||
this.dimensions = {
|
this.dimensions = {
|
||||||
width: candidate_width,
|
width: candidate_width,
|
||||||
@ -236,10 +239,10 @@ class PlayerData {
|
|||||||
};
|
};
|
||||||
const ths = this;
|
const ths = this;
|
||||||
if(this.element) {
|
if(this.element) {
|
||||||
this.element.removeEventListener('mousemove', (event) => ths.panHandler(event));
|
this.element.removeEventListener('mousemove', (event) => ths.panListener);
|
||||||
}
|
}
|
||||||
this.element = playerCandidateNode;
|
this.element = playerCandidateNode;
|
||||||
this.element.addEventListener('mousemove', (event) => ths.panHandler(event));
|
this.element.addEventListener('mousemove', (event) => ths.panListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,15 +14,25 @@ class VideoData {
|
|||||||
// player dimensions need to be in:
|
// player dimensions need to be in:
|
||||||
// this.player.dimensions
|
// this.player.dimensions
|
||||||
this.pageInfo = pageInfo;
|
this.pageInfo = pageInfo;
|
||||||
|
this.vdid = (Math.random()*100).toFixed();
|
||||||
|
if (Debug.init) {
|
||||||
|
console.log("[VideoData::ctor] Created videoData with vdid", this.vdid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
firstTimeArdInit(){
|
firstTimeArdInit(){
|
||||||
|
if(this.destroyed) {
|
||||||
|
throw {error: 'VIDEO_DATA_DESTROYED', data: {videoData: this}};
|
||||||
|
}
|
||||||
if(! this.arSetupComplete){
|
if(! this.arSetupComplete){
|
||||||
this.arDetector = new ArDetector(this);
|
this.arDetector = new ArDetector(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initArDetection() {
|
initArDetection() {
|
||||||
|
if(this.destroyed) {
|
||||||
|
throw {error: 'VIDEO_DATA_DESTROYED', data: {videoData: this}};
|
||||||
|
}
|
||||||
if(this.arDetector){
|
if(this.arDetector){
|
||||||
this.arDetector.init();
|
this.arDetector.init();
|
||||||
}
|
}
|
||||||
@ -33,6 +43,9 @@ class VideoData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startArDetection() {
|
startArDetection() {
|
||||||
|
if(this.destroyed) {
|
||||||
|
throw {error: 'VIDEO_DATA_DESTROYED', data: {videoData: this}};
|
||||||
|
}
|
||||||
if(!this.arDetector) {
|
if(!this.arDetector) {
|
||||||
this.arDetector.init();
|
this.arDetector.init();
|
||||||
}
|
}
|
||||||
@ -46,10 +59,11 @@ class VideoData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
if(Debug.debug){
|
if(Debug.debug || Debug.init){
|
||||||
console.log("[VideoData::destroy] received destroy command");
|
console.log(`[VideoData::destroy] <vdid:${this.vdid}> received destroy command`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.pause();
|
||||||
this.destroyed = true;
|
this.destroyed = true;
|
||||||
if(this.arDetector){
|
if(this.arDetector){
|
||||||
this.arDetector.stop();
|
this.arDetector.stop();
|
||||||
@ -81,6 +95,9 @@ class VideoData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resume(){
|
resume(){
|
||||||
|
if(this.destroyed) {
|
||||||
|
throw {error: 'VIDEO_DATA_DESTROYED', data: {videoData: this}};
|
||||||
|
}
|
||||||
this.paused = false;
|
this.paused = false;
|
||||||
try {
|
try {
|
||||||
this.resizer.start();
|
this.resizer.start();
|
||||||
@ -112,6 +129,9 @@ class VideoData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
panHandler(event) {
|
panHandler(event) {
|
||||||
|
if(this.destroyed) {
|
||||||
|
throw {error: 'VIDEO_DATA_DESTROYED', data: {videoData: this}};
|
||||||
|
}
|
||||||
if(!this.resizer) {
|
if(!this.resizer) {
|
||||||
this.destroy();
|
this.destroy();
|
||||||
return;
|
return;
|
||||||
|
@ -15,17 +15,27 @@ class ArDetector {
|
|||||||
this.fallbackMode = false;
|
this.fallbackMode = false;
|
||||||
|
|
||||||
this.blackLevel = this.settings.active.arDetect.blackLevel_default;
|
this.blackLevel = this.settings.active.arDetect.blackLevel_default;
|
||||||
|
|
||||||
|
this.arid = (Math.random()*100).toFixed();
|
||||||
|
|
||||||
|
if (Debug.init) {
|
||||||
|
console.log("[ArDetector::ctor] creating new ArDetector. arid:", this.arid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init(){
|
init(){
|
||||||
if(Debug.debug){
|
if (Debug.debug || Debug.init) {
|
||||||
console.log("[ArDetect::init] Initializing autodetection")
|
console.log("[ArDetect::init] Initializing autodetection. arid:", this.arid);
|
||||||
}
|
}
|
||||||
this.setup(this.settings.active.arDetect.hSamples, this.settings.active.arDetect.vSamples);
|
this.setup(this.settings.active.arDetect.hSamples, this.settings.active.arDetect.vSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy(){
|
destroy(){
|
||||||
|
if(Debug.debug || Debug.init) {
|
||||||
|
console.log(`[ArDetect::destroy] <arid:${this.arid}>`)
|
||||||
|
}
|
||||||
this.debugCanvas.destroy();
|
this.debugCanvas.destroy();
|
||||||
|
this.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
setup(cwidth, cheight, forceStart){
|
setup(cwidth, cheight, forceStart){
|
||||||
@ -34,8 +44,8 @@ class ArDetector {
|
|||||||
this.edgeDetector = new EdgeDetect(this);
|
this.edgeDetector = new EdgeDetect(this);
|
||||||
this.debugCanvas = new DebugCanvas(this);
|
this.debugCanvas = new DebugCanvas(this);
|
||||||
|
|
||||||
if(Debug.debug) {
|
if(Debug.debug || Debug.init) {
|
||||||
console.log("[ArDetect::setup] Starting autodetection setup");
|
console.log("[ArDetect::setup] Starting autodetection setup. arid:", this.arid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.fallbackMode || cheight !== this.settings.active.arDetect.hSamples) {
|
if (this.fallbackMode || cheight !== this.settings.active.arDetect.hSamples) {
|
||||||
|
@ -26,7 +26,7 @@ class PageInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
if(Debug.debug){
|
if(Debug.debug || Debug.init){
|
||||||
console.log("[PageInfo::destroy] destroying all videos!")
|
console.log("[PageInfo::destroy] destroying all videos!")
|
||||||
}
|
}
|
||||||
if(this.rescanTimer){
|
if(this.rescanTimer){
|
||||||
|
@ -49,7 +49,9 @@ class Resizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start(){
|
start(){
|
||||||
this.startCssWatcher();
|
if(!this.destroyed) {
|
||||||
|
this.startCssWatcher();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stop(){
|
stop(){
|
||||||
@ -57,7 +59,7 @@ class Resizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy(){
|
destroy(){
|
||||||
if(Debug.debug){
|
if(Debug.debug || Debug.init){
|
||||||
console.log(`[Resizer::destroy] <rid:${this.resizerId}> received destroy command.`);
|
console.log(`[Resizer::destroy] <rid:${this.resizerId}> received destroy command.`);
|
||||||
}
|
}
|
||||||
this.destroyed = true;
|
this.destroyed = true;
|
||||||
@ -91,7 +93,7 @@ class Resizer {
|
|||||||
this.videoData.destroy();
|
this.videoData.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// pause AR on basic stretch, unpause when using other mdoes
|
// // pause AR on basic stretch, unpause when using other mdoes
|
||||||
// fir sine reason unpause doesn't unpause. investigate that later
|
// fir sine reason unpause doesn't unpause. investigate that later
|
||||||
// if (this.stretcher.mode === StretchMode.BASIC) {
|
// if (this.stretcher.mode === StretchMode.BASIC) {
|
||||||
// this.conf.arDetector.pause();
|
// this.conf.arDetector.pause();
|
||||||
@ -186,9 +188,13 @@ class Resizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startCssWatcher(){
|
startCssWatcher(){
|
||||||
|
if(Debug.debug) {
|
||||||
|
console.log("[Resizer.js::startCssWatcher] starting css watcher. Is resizer destroyed?", this.destroyed);
|
||||||
|
}
|
||||||
if (this.destroyed) {
|
if (this.destroyed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.haltCssWatcher = false;
|
// this.haltCssWatcher = false;
|
||||||
if(!this.cssWatcherTimer){
|
if(!this.cssWatcherTimer){
|
||||||
this.scheduleCssWatcher(1);
|
this.scheduleCssWatcher(1);
|
||||||
@ -441,6 +447,7 @@ class Resizer {
|
|||||||
if(Debug.debug) {
|
if(Debug.debug) {
|
||||||
console.log("[Resizer::cssCheck] <rid:"+this.resizerId+"> destroyed flag is set, we shouldnt be running");
|
console.log("[Resizer::cssCheck] <rid:"+this.resizerId+"> destroyed flag is set, we shouldnt be running");
|
||||||
}
|
}
|
||||||
|
this.stopCssWatcher();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,8 +766,10 @@ document.addEventListener("click", (e) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e.target.classList.contains("_zoom_reset")) {
|
if (e.target.classList.contains("_zoom_reset")) {
|
||||||
|
zoom_videoScale = scale;
|
||||||
VideoPanel.labels.zoomLevel.textContent = 100;
|
VideoPanel.labels.zoomLevel.textContent = 100;
|
||||||
VideoPanel.inputs.zoomSlider.value = 0; // log₂(1)
|
VideoPanel.inputs.zoomSlider.value = 0; // log₂(1)
|
||||||
|
|
||||||
command.cmd = 'set-zoom';
|
command.cmd = 'set-zoom';
|
||||||
command.zoom = 1;
|
command.zoom = 1;
|
||||||
return command;
|
return command;
|
||||||
|
Loading…
Reference in New Issue
Block a user