mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-12 23:36:15 -08:00
add floatCeil
This commit is contained in:
1 parent
18ca81e2ed
commit
a244879a3e
4 files changed
+15
-6
No files matched your search
@@ -341,6 +341,10 @@
|
||||
function clamp(num, a, b) {
|
||||
return Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b));
|
||||
}
|
||||
function floatCeil(num) {
|
||||
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
||||
return Math.ceil(num * Math.pow(10, precision)) / Math.pow(10, precision);
|
||||
}
|
||||
function getExt(url) {
|
||||
if (url.includes('?')) {
|
||||
return getExt(url.split('?')[0]);
|
||||
@@ -525,6 +529,7 @@
|
||||
errorHandle: errorHandle,
|
||||
hasOwnProperty: hasOwnProperty,
|
||||
clamp: clamp,
|
||||
floatCeil: floatCeil,
|
||||
getExt: getExt,
|
||||
secondToTime: secondToTime,
|
||||
sleep: sleep,
|
||||
@@ -1904,11 +1909,11 @@
|
||||
$container.classList.add('artplayer-auto-size');
|
||||
|
||||
if (containerRatio > videoRatio) {
|
||||
var percentage = height * videoRatio / width * 100;
|
||||
var percentage = floatCeil(height * videoRatio / width * 100, 1);
|
||||
setStyle($player, 'width', "".concat(percentage, "%"));
|
||||
setStyle($player, 'height', '100%');
|
||||
} else {
|
||||
var _percentage = width / videoRatio / height * 100;
|
||||
var _percentage = floatCeil(width / videoRatio / height * 100, 1);
|
||||
|
||||
setStyle($player, 'width', '100%');
|
||||
setStyle($player, 'height', "".concat(_percentage, "%"));
|
||||
|
||||
Reference in new issue
Block a user