remove listeners on contract
This commit is contained in:
parent
f88883887a
commit
2a3f7ecd54
@ -8036,18 +8036,23 @@
|
|||||||
return ImageExpand.contract(post);
|
return ImageExpand.contract(post);
|
||||||
},
|
},
|
||||||
contract: function(post) {
|
contract: function(post) {
|
||||||
var video, _ref;
|
var cb, eventName, video, _ref, _ref1;
|
||||||
if (post.file.isVideo && (video = post.file.fullImage)) {
|
if (post.file.isVideo && (video = post.file.fullImage)) {
|
||||||
video.pause();
|
video.pause();
|
||||||
|
_ref = ImageExpand.videoCB;
|
||||||
|
for (eventName in _ref) {
|
||||||
|
cb = _ref[eventName];
|
||||||
|
$.off(video, eventName, cb);
|
||||||
|
}
|
||||||
TrashQueue.add(video);
|
TrashQueue.add(video);
|
||||||
|
if ((_ref1 = post.file.videoControls) != null) {
|
||||||
|
_ref1.map($.rm);
|
||||||
|
}
|
||||||
|
delete post.file.videoControls;
|
||||||
}
|
}
|
||||||
$.rmClass(post.nodes.root, 'expanded-image');
|
$.rmClass(post.nodes.root, 'expanded-image');
|
||||||
$.rmClass(post.file.thumb, 'expanding');
|
$.rmClass(post.file.thumb, 'expanding');
|
||||||
post.file.isExpanded = false;
|
return post.file.isExpanded = false;
|
||||||
if ((_ref = post.file.videoControls) != null) {
|
|
||||||
_ref.map($.rm);
|
|
||||||
}
|
|
||||||
return delete post.file.videoControls;
|
|
||||||
},
|
},
|
||||||
expand: function(post, src) {
|
expand: function(post, src) {
|
||||||
var img, isVideo, naturalHeight, thumb, _ref;
|
var img, isVideo, naturalHeight, thumb, _ref;
|
||||||
@ -8110,8 +8115,28 @@
|
|||||||
return window.scrollBy(0, post.nodes.root.getBoundingClientRect().bottom - bottom);
|
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) {
|
setupVideo: function(post) {
|
||||||
var contract, file, play, video;
|
var cb, contract, eventName, file, play, video, _ref;
|
||||||
file = post.file;
|
file = post.file;
|
||||||
video = file.fullImage;
|
video = file.fullImage;
|
||||||
file.videoControls = [];
|
file.videoControls = [];
|
||||||
@ -8126,25 +8151,12 @@
|
|||||||
return ImageExpand.contract(post);
|
return ImageExpand.contract(post);
|
||||||
});
|
});
|
||||||
file.videoControls.push($.tn('\u00A0'), contract);
|
file.videoControls.push($.tn('\u00A0'), contract);
|
||||||
file.mousedown = false;
|
video.dataset.mousedown = 'false';
|
||||||
$.on(video, 'mousedown', function(e) {
|
_ref = ImageExpand.videoCB;
|
||||||
if (e.button === 0) {
|
for (eventName in _ref) {
|
||||||
return file.mousedown = true;
|
cb = _ref[eventName];
|
||||||
}
|
$.on(video, eventName, cb);
|
||||||
});
|
}
|
||||||
$.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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (Conf['Autoplay']) {
|
if (Conf['Autoplay']) {
|
||||||
video.play();
|
video.play();
|
||||||
|
|||||||
@ -8075,18 +8075,23 @@
|
|||||||
return ImageExpand.contract(post);
|
return ImageExpand.contract(post);
|
||||||
},
|
},
|
||||||
contract: function(post) {
|
contract: function(post) {
|
||||||
var video, _ref;
|
var cb, eventName, video, _ref, _ref1;
|
||||||
if (post.file.isVideo && (video = post.file.fullImage)) {
|
if (post.file.isVideo && (video = post.file.fullImage)) {
|
||||||
video.pause();
|
video.pause();
|
||||||
|
_ref = ImageExpand.videoCB;
|
||||||
|
for (eventName in _ref) {
|
||||||
|
cb = _ref[eventName];
|
||||||
|
$.off(video, eventName, cb);
|
||||||
|
}
|
||||||
TrashQueue.add(video);
|
TrashQueue.add(video);
|
||||||
|
if ((_ref1 = post.file.videoControls) != null) {
|
||||||
|
_ref1.map($.rm);
|
||||||
|
}
|
||||||
|
delete post.file.videoControls;
|
||||||
}
|
}
|
||||||
$.rmClass(post.nodes.root, 'expanded-image');
|
$.rmClass(post.nodes.root, 'expanded-image');
|
||||||
$.rmClass(post.file.thumb, 'expanding');
|
$.rmClass(post.file.thumb, 'expanding');
|
||||||
post.file.isExpanded = false;
|
return post.file.isExpanded = false;
|
||||||
if ((_ref = post.file.videoControls) != null) {
|
|
||||||
_ref.map($.rm);
|
|
||||||
}
|
|
||||||
return delete post.file.videoControls;
|
|
||||||
},
|
},
|
||||||
expand: function(post, src) {
|
expand: function(post, src) {
|
||||||
var img, isVideo, naturalHeight, thumb, _ref;
|
var img, isVideo, naturalHeight, thumb, _ref;
|
||||||
@ -8149,8 +8154,28 @@
|
|||||||
return window.scrollBy(0, post.nodes.root.getBoundingClientRect().bottom - bottom);
|
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) {
|
setupVideo: function(post) {
|
||||||
var contract, file, play, video;
|
var cb, contract, eventName, file, play, video, _ref;
|
||||||
file = post.file;
|
file = post.file;
|
||||||
video = file.fullImage;
|
video = file.fullImage;
|
||||||
file.videoControls = [];
|
file.videoControls = [];
|
||||||
@ -8165,25 +8190,12 @@
|
|||||||
return ImageExpand.contract(post);
|
return ImageExpand.contract(post);
|
||||||
});
|
});
|
||||||
file.videoControls.push($.tn('\u00A0'), contract);
|
file.videoControls.push($.tn('\u00A0'), contract);
|
||||||
file.mousedown = false;
|
video.dataset.mousedown = 'false';
|
||||||
$.on(video, 'mousedown', function(e) {
|
_ref = ImageExpand.videoCB;
|
||||||
if (e.button === 0) {
|
for (eventName in _ref) {
|
||||||
return file.mousedown = true;
|
cb = _ref[eventName];
|
||||||
}
|
$.on(video, eventName, cb);
|
||||||
});
|
}
|
||||||
$.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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (Conf['Autoplay']) {
|
if (Conf['Autoplay']) {
|
||||||
video.play();
|
video.play();
|
||||||
|
|||||||
@ -89,12 +89,14 @@ ImageExpand =
|
|||||||
contract: (post) ->
|
contract: (post) ->
|
||||||
if post.file.isVideo and video = post.file.fullImage
|
if post.file.isVideo and video = post.file.fullImage
|
||||||
video.pause()
|
video.pause()
|
||||||
|
for eventName, cb of ImageExpand.videoCB
|
||||||
|
$.off video, eventName, cb
|
||||||
TrashQueue.add video
|
TrashQueue.add video
|
||||||
|
post.file.videoControls?.map($.rm)
|
||||||
|
delete post.file.videoControls
|
||||||
$.rmClass post.nodes.root, 'expanded-image'
|
$.rmClass post.nodes.root, 'expanded-image'
|
||||||
$.rmClass post.file.thumb, 'expanding'
|
$.rmClass post.file.thumb, 'expanding'
|
||||||
post.file.isExpanded = false
|
post.file.isExpanded = false
|
||||||
post.file.videoControls?.map($.rm)
|
|
||||||
delete post.file.videoControls
|
|
||||||
|
|
||||||
expand: (post, src) ->
|
expand: (post, src) ->
|
||||||
# Do not expand images of hidden/filtered replies, or already expanded pictures.
|
# Do not expand images of hidden/filtered replies, or already expanded pictures.
|
||||||
@ -140,6 +142,14 @@ ImageExpand =
|
|||||||
return unless bottom <= 0
|
return unless bottom <= 0
|
||||||
window.scrollBy 0, post.nodes.root.getBoundingClientRect().bottom - bottom
|
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) ->
|
setupVideo: (post) ->
|
||||||
{file} = post
|
{file} = post
|
||||||
video = file.fullImage
|
video = file.fullImage
|
||||||
@ -154,13 +164,9 @@ ImageExpand =
|
|||||||
$.on contract, 'click', (e) -> ImageExpand.contract post
|
$.on contract, 'click', (e) -> ImageExpand.contract post
|
||||||
file.videoControls.push $.tn('\u00A0'), contract
|
file.videoControls.push $.tn('\u00A0'), contract
|
||||||
# drag left to contract
|
# drag left to contract
|
||||||
file.mousedown = false
|
video.dataset.mousedown = 'false'
|
||||||
$.on video, 'mousedown', (e) -> file.mousedown = true if e.button is 0
|
for eventName, cb of ImageExpand.videoCB
|
||||||
$.on video, 'mouseup', (e) -> file.mousedown = false if e.button is 0
|
$.on video, eventName, cb
|
||||||
$.on video, 'mouseover', (e) -> file.mousedown = false
|
|
||||||
$.on video, 'mouseout', (e) ->
|
|
||||||
if file.mousedown and e.clientX <= video.getBoundingClientRect().left
|
|
||||||
ImageExpand.contract post
|
|
||||||
if Conf['Autoplay']
|
if Conf['Autoplay']
|
||||||
video.play()
|
video.play()
|
||||||
else unless video.controls
|
else unless video.controls
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user