mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 20:17:24 +08:00
improve cover view
This commit is contained in:
@@ -3492,7 +3492,9 @@ foreach ($rows as $row)
|
|||||||
$coverSrc = '';
|
$coverSrc = '';
|
||||||
if ($imdb_id = parse_imdb_id($row["url"])) {
|
if ($imdb_id = parse_imdb_id($row["url"])) {
|
||||||
try {
|
try {
|
||||||
$coverSrc = $imdb->getMovie($imdb_id)->photo(false);
|
if ($imdb->getCacheStatus($imdb_id) == 1) {
|
||||||
|
$coverSrc = $imdb->getMovie($imdb_id)->photo(false);
|
||||||
|
}
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
do_log("torrent: {$row['id']} get cover from imdb error: ".$exception->getMessage() . "\n[stacktrace]\n" . $exception->getTraceAsString(), 'error');
|
do_log("torrent: {$row['id']} get cover from imdb error: ".$exception->getMessage() . "\n[stacktrace]\n" . $exception->getTraceAsString(), 'error');
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+41
-21
@@ -8,38 +8,58 @@ jQuery(document).ready(function () {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// preview
|
function getImgPosition(e, imgEle) {
|
||||||
function getPosition(e, imgEle) {
|
|
||||||
let imgWidth = imgEle.prop('naturalWidth')
|
let imgWidth = imgEle.prop('naturalWidth')
|
||||||
let imgHeight = imgEle.prop("naturalHeight")
|
let imgHeight = imgEle.prop("naturalHeight")
|
||||||
console.log(`imgWidth: ${imgWidth}, imgHeight: ${imgHeight}`)
|
|
||||||
let ratio = imgWidth / imgHeight;
|
let ratio = imgWidth / imgHeight;
|
||||||
if (imgWidth > window.innerWidth) {
|
let offsetX = 10;
|
||||||
imgWidth = window.innerWidth;
|
let offsetY = 10;
|
||||||
imgHeight = imgWidth / ratio;
|
let width = window.innerWidth - e.pageX;
|
||||||
|
let height = window.innerHeight - e.pageY;
|
||||||
|
let changeOffsetY = false;
|
||||||
|
let changeOffsetX = false;
|
||||||
|
if (e.pageX > window.innerWidth / 2 && e.pageX + imgWidth > window.innerWidth) {
|
||||||
|
changeOffsetX = true
|
||||||
|
width = e.pageX
|
||||||
}
|
}
|
||||||
if (imgHeight > window.innerHeight) {
|
if (e.pageY > window.innerHeight / 2 && e.pageY + imgHeight > window.innerHeight) {
|
||||||
imgHeight = window.innerHeight;
|
changeOffsetY = true
|
||||||
|
height = e.pageY
|
||||||
|
}
|
||||||
|
let log = `imgWidth: ${imgWidth}, imgHeight: ${imgHeight}, width: ${width}, height: ${height}, offsetX: ${offsetX}, offsetY: ${offsetY}, changeOffsetX: ${changeOffsetX}, changeOffsetY: ${changeOffsetY}`
|
||||||
|
console.log(log)
|
||||||
|
if (imgWidth > width) {
|
||||||
|
imgWidth = width;
|
||||||
|
imgHeight = imgHeight = imgWidth / ratio;
|
||||||
|
}
|
||||||
|
if (imgHeight > height) {
|
||||||
|
imgHeight = height;
|
||||||
imgWidth = imgHeight * ratio;
|
imgWidth = imgHeight * ratio;
|
||||||
}
|
}
|
||||||
let width = imgWidth, height= imgHeight;
|
if (changeOffsetX) {
|
||||||
let left = e.pageX + 10;
|
offsetX = -(e.pageX - width + 10)
|
||||||
if (left + imgWidth > window.innerWidth) {
|
|
||||||
left = e.pageX - 10 - imgWidth
|
|
||||||
}
|
}
|
||||||
let top = e.pageY + 10;
|
if (changeOffsetY) {
|
||||||
if (top + imgHeight > window.innerHeight) {
|
offsetY = -(e.pageY - imgHeight/2)
|
||||||
top = e.pageY - imgHeight / 2
|
}
|
||||||
|
return {imgWidth, imgHeight,offsetX, offsetY}
|
||||||
|
}
|
||||||
|
|
||||||
|
// preview
|
||||||
|
function getPosition(e, position) {
|
||||||
|
return {
|
||||||
|
left: e.pageX + position.offsetX,
|
||||||
|
top: e.pageY + position.offsetY,
|
||||||
|
width: position.imgWidth,
|
||||||
|
height: position.imgHeight
|
||||||
}
|
}
|
||||||
let result = {left, top, width, height}
|
|
||||||
console.log(result)
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
var previewEle = jQuery('#nexus-preview')
|
var previewEle = jQuery('#nexus-preview')
|
||||||
var imgEle, selector = '.preview'
|
var imgEle, selector = 'img.preview', imgPosition
|
||||||
jQuery("body").on("mouseover", selector, function (e) {
|
jQuery("body").on("mouseover", selector, function (e) {
|
||||||
imgEle = jQuery(this);
|
imgEle = jQuery(this);
|
||||||
let position = getPosition(e, imgEle)
|
imgPosition = getImgPosition(e, imgEle)
|
||||||
|
let position = getPosition(e, imgPosition)
|
||||||
let src = imgEle.attr("src")
|
let src = imgEle.attr("src")
|
||||||
if (src) {
|
if (src) {
|
||||||
previewEle.attr("src", src).css(position).fadeIn("fast");
|
previewEle.attr("src", src).css(position).fadeIn("fast");
|
||||||
@@ -47,7 +67,7 @@ jQuery(document).ready(function () {
|
|||||||
}).on("mouseout", selector, function (e) {
|
}).on("mouseout", selector, function (e) {
|
||||||
previewEle.fadeOut("fast");
|
previewEle.fadeOut("fast");
|
||||||
}).on("mousemove", selector, function (e) {
|
}).on("mousemove", selector, function (e) {
|
||||||
let position = getPosition(e, imgEle)
|
let position = getPosition(e, imgPosition)
|
||||||
previewEle.css(position)
|
previewEle.css(position)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user