remove listeners on contract
This commit is contained in:
parent
80b2eae41b
commit
113dde4eae
@ -7675,18 +7675,23 @@
|
||||
return ImageExpand.contract(post);
|
||||
},
|
||||
contract: function(post) {
|
||||
var video, _ref;
|
||||
var cb, eventName, video, _ref, _ref1;
|
||||
if (post.file.isVideo && (video = post.file.fullImage)) {
|
||||
video.pause();
|
||||
_ref = ImageExpand.videoCB;
|
||||
for (eventName in _ref) {
|
||||
cb = _ref[eventName];
|
||||
$.off(video, eventName, cb);
|
||||
}
|
||||
TrashQueue.add(video);
|
||||
if ((_ref1 = post.file.videoControls) != null) {
|
||||
_ref1.map($.rm);
|
||||
}
|
||||
delete post.file.videoControls;
|
||||
}
|
||||
$.rmClass(post.nodes.root, 'expanded-image');
|
||||
$.rmClass(post.file.thumb, 'expanding');
|
||||
post.file.isExpanded = false;
|
||||
if ((_ref = post.file.videoControls) != null) {
|
||||
_ref.map($.rm);
|
||||
}
|
||||
return delete post.file.videoControls;
|
||||
return post.file.isExpanded = false;
|
||||
},
|
||||
expand: function(post, src) {
|
||||
var img, isVideo, naturalHeight, thumb, _ref;
|
||||
@ -7749,8 +7754,28 @@
|
||||
return window.scrollBy(0, post.nodes.root.getBoundingClientRect().bottom - bottom);
|
||||
});
|
||||
},
|
||||
videoCB: {
|
||||
mousedown: function(e) {
|
||||
if (e.button === 0) {
|
||||
return this.dataset.mousedown = 'true';
|
||||
}
|
||||
},
|
||||
mouseup: function(e) {
|
||||
if (e.button === 0) {
|
||||
return this.dataset.mousedown = 'false';
|
||||
}
|
||||
},
|
||||
mouseover: function(e) {
|
||||
return this.dataset.mousedown = 'false';
|
||||
},
|
||||
mouseout: function(e) {
|
||||
if (this.dataset.mousedown === 'true' && e.clientX <= this.getBoundingClientRect().left) {
|
||||
return ImageExpand.contract(Get.postFromNode(this));
|
||||
}
|
||||
}
|
||||
},
|
||||
setupVideo: function(post) {
|
||||
var contract, file, play, video;
|
||||
var cb, contract, eventName, file, play, video, _ref;
|
||||
file = post.file;
|
||||
video = file.fullImage;
|
||||
file.videoControls = [];
|
||||
@ -7765,25 +7790,12 @@
|
||||
return ImageExpand.contract(post);
|
||||
});
|
||||
file.videoControls.push($.tn('\u00A0'), contract);
|
||||
file.mousedown = false;
|
||||
$.on(video, 'mousedown', function(e) {
|
||||
if (e.button === 0) {
|
||||
return file.mousedown = true;
|
||||
}
|
||||
});
|
||||
$.on(video, 'mouseup', function(e) {
|
||||
if (e.button === 0) {
|
||||
return file.mousedown = false;
|
||||
}
|
||||
});
|
||||
$.on(video, 'mouseover', function(e) {
|
||||
return file.mousedown = false;
|
||||
});
|
||||
$.on(video, 'mouseout', function(e) {
|
||||
if (file.mousedown && e.clientX <= video.getBoundingClientRect().left) {
|
||||
return ImageExpand.contract(post);
|
||||
}
|
||||
});
|
||||
video.dataset.mousedown = 'false';
|
||||
_ref = ImageExpand.videoCB;
|
||||
for (eventName in _ref) {
|
||||
cb = _ref[eventName];
|
||||
$.on(video, eventName, cb);
|
||||
}
|
||||
}
|
||||
if (Conf['Autoplay']) {
|
||||
video.play();
|
||||
|
||||
@ -7694,18 +7694,23 @@
|
||||
return ImageExpand.contract(post);
|
||||
},
|
||||
contract: function(post) {
|
||||
var video, _ref;
|
||||
var cb, eventName, video, _ref, _ref1;
|
||||
if (post.file.isVideo && (video = post.file.fullImage)) {
|
||||
video.pause();
|
||||
_ref = ImageExpand.videoCB;
|
||||
for (eventName in _ref) {
|
||||
cb = _ref[eventName];
|
||||
$.off(video, eventName, cb);
|
||||
}
|
||||
TrashQueue.add(video);
|
||||
if ((_ref1 = post.file.videoControls) != null) {
|
||||
_ref1.map($.rm);
|
||||
}
|
||||
delete post.file.videoControls;
|
||||
}
|
||||
$.rmClass(post.nodes.root, 'expanded-image');
|
||||
$.rmClass(post.file.thumb, 'expanding');
|
||||
post.file.isExpanded = false;
|
||||
if ((_ref = post.file.videoControls) != null) {
|
||||
_ref.map($.rm);
|
||||
}
|
||||
return delete post.file.videoControls;
|
||||
return post.file.isExpanded = false;
|
||||
},
|
||||
expand: function(post, src) {
|
||||
var img, isVideo, naturalHeight, thumb, _ref;
|
||||
@ -7768,8 +7773,28 @@
|
||||
return window.scrollBy(0, post.nodes.root.getBoundingClientRect().bottom - bottom);
|
||||
});
|
||||
},
|
||||
videoCB: {
|
||||
mousedown: function(e) {
|
||||
if (e.button === 0) {
|
||||
return this.dataset.mousedown = 'true';
|
||||
}
|
||||
},
|
||||
mouseup: function(e) {
|
||||
if (e.button === 0) {
|
||||
return this.dataset.mousedown = 'false';
|
||||
}
|
||||
},
|
||||
mouseover: function(e) {
|
||||
return this.dataset.mousedown = 'false';
|
||||
},
|
||||
mouseout: function(e) {
|
||||
if (this.dataset.mousedown === 'true' && e.clientX <= this.getBoundingClientRect().left) {
|
||||
return ImageExpand.contract(Get.postFromNode(this));
|
||||
}
|
||||
}
|
||||
},
|
||||
setupVideo: function(post) {
|
||||
var contract, file, play, video;
|
||||
var cb, contract, eventName, file, play, video, _ref;
|
||||
file = post.file;
|
||||
video = file.fullImage;
|
||||
file.videoControls = [];
|
||||
@ -7784,25 +7809,12 @@
|
||||
return ImageExpand.contract(post);
|
||||
});
|
||||
file.videoControls.push($.tn('\u00A0'), contract);
|
||||
file.mousedown = false;
|
||||
$.on(video, 'mousedown', function(e) {
|
||||
if (e.button === 0) {
|
||||
return file.mousedown = true;
|
||||
}
|
||||
});
|
||||
$.on(video, 'mouseup', function(e) {
|
||||
if (e.button === 0) {
|
||||
return file.mousedown = false;
|
||||
}
|
||||
});
|
||||
$.on(video, 'mouseover', function(e) {
|
||||
return file.mousedown = false;
|
||||
});
|
||||
$.on(video, 'mouseout', function(e) {
|
||||
if (file.mousedown && e.clientX <= video.getBoundingClientRect().left) {
|
||||
return ImageExpand.contract(post);
|
||||
}
|
||||
});
|
||||
video.dataset.mousedown = 'false';
|
||||
_ref = ImageExpand.videoCB;
|
||||
for (eventName in _ref) {
|
||||
cb = _ref[eventName];
|
||||
$.on(video, eventName, cb);
|
||||
}
|
||||
}
|
||||
if (Conf['Autoplay']) {
|
||||
video.play();
|
||||
|
||||
@ -92,12 +92,14 @@ ImageExpand =
|
||||
contract: (post) ->
|
||||
if post.file.isVideo and video = post.file.fullImage
|
||||
video.pause()
|
||||
for eventName, cb of ImageExpand.videoCB
|
||||
$.off video, eventName, cb
|
||||
TrashQueue.add video
|
||||
post.file.videoControls?.map($.rm)
|
||||
delete post.file.videoControls
|
||||
$.rmClass post.nodes.root, 'expanded-image'
|
||||
$.rmClass post.file.thumb, 'expanding'
|
||||
post.file.isExpanded = false
|
||||
post.file.videoControls?.map($.rm)
|
||||
delete post.file.videoControls
|
||||
|
||||
expand: (post, src) ->
|
||||
# Do not expand images of hidden/filtered replies, or already expanded pictures.
|
||||
@ -143,6 +145,14 @@ ImageExpand =
|
||||
return unless bottom <= 0
|
||||
window.scrollBy 0, post.nodes.root.getBoundingClientRect().bottom - bottom
|
||||
|
||||
videoCB:
|
||||
mousedown: (e) -> @dataset.mousedown = 'true' if e.button is 0
|
||||
mouseup: (e) -> @dataset.mousedown = 'false' if e.button is 0
|
||||
mouseover: (e) -> @dataset.mousedown = 'false'
|
||||
mouseout: (e) ->
|
||||
if @dataset.mousedown is 'true' and e.clientX <= @getBoundingClientRect().left
|
||||
ImageExpand.contract (Get.postFromNode @)
|
||||
|
||||
setupVideo: (post) ->
|
||||
{file} = post
|
||||
video = file.fullImage
|
||||
@ -157,13 +167,9 @@ ImageExpand =
|
||||
$.on contract, 'click', (e) -> ImageExpand.contract post
|
||||
file.videoControls.push $.tn('\u00A0'), contract
|
||||
# drag left to contract
|
||||
file.mousedown = false
|
||||
$.on video, 'mousedown', (e) -> file.mousedown = true if e.button is 0
|
||||
$.on video, 'mouseup', (e) -> file.mousedown = false if e.button is 0
|
||||
$.on video, 'mouseover', (e) -> file.mousedown = false
|
||||
$.on video, 'mouseout', (e) ->
|
||||
if file.mousedown and e.clientX <= video.getBoundingClientRect().left
|
||||
ImageExpand.contract post
|
||||
video.dataset.mousedown = 'false'
|
||||
for eventName, cb of ImageExpand.videoCB
|
||||
$.on video, eventName, cb
|
||||
if Conf['Autoplay']
|
||||
video.play()
|
||||
else unless video.controls
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user