remove listeners on contract
This commit is contained in:
parent
f88883887a
commit
2a3f7ecd54
@ -8036,18 +8036,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;
|
||||
@ -8110,8 +8115,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 = [];
|
||||
@ -8126,25 +8151,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();
|
||||
|
||||
@ -8075,18 +8075,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;
|
||||
@ -8149,8 +8154,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 = [];
|
||||
@ -8165,25 +8190,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();
|
||||
|
||||
@ -89,12 +89,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.
|
||||
@ -140,6 +142,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
|
||||
@ -154,13 +164,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