up
This commit is contained in:
@@ -21,42 +21,41 @@
|
|||||||
|
|
||||||
|
|
||||||
function HoverShowMenu() {
|
function HoverShowMenu() {
|
||||||
$("#js-menu-big .box-item .item").on("mousemove", function () {
|
const $menuBig = $('#js-menu-big');
|
||||||
let $checkMenu = $('#js-menu-big').hasClass('active');
|
const $hoverMenu = $('#js-hover-menu');
|
||||||
if ($checkMenu) {
|
|
||||||
let $hoverMenu = $('#js-hover-menu');
|
$menuBig.find('.box-item .item').on('mousemove', function () {
|
||||||
let $this = $(this).parents('.box-item');
|
if ($menuBig.hasClass('active')) {
|
||||||
let $hoverContent = $this.find('.hover-menu');
|
const $parentItem = $(this).closest('.box-item');
|
||||||
|
const $hoverContent = $parentItem.find('.hover-menu');
|
||||||
|
|
||||||
if ($hoverContent.length) {
|
if ($hoverContent.length) {
|
||||||
let offset = $this.offset();
|
const offset = $parentItem.offset();
|
||||||
let x = offset.left + $("#js-menu-big").width();
|
const menuWidth = $menuBig.width();
|
||||||
let y = offset.top;
|
const hoverHeight = $hoverContent.outerHeight();
|
||||||
|
const windowHeight = $(window).height();
|
||||||
|
const maxY = $(window).scrollTop() + windowHeight;
|
||||||
|
|
||||||
// Kiểm tra nếu hoverContent bị tràn màn hình ở dưới
|
let posX = offset.left + menuWidth;
|
||||||
let hoverHeight = $hoverContent.outerHeight();
|
let posY = offset.top;
|
||||||
let windowHeight = $(window).height();
|
|
||||||
let maxY = $(window).scrollTop() + windowHeight; // Vị trí Y tối đa có thể hiển thị
|
|
||||||
let newY = y;
|
|
||||||
|
|
||||||
if (y + hoverHeight > maxY) {
|
if (posY + hoverHeight > maxY) {
|
||||||
newY = maxY - hoverHeight - 10;
|
posY = maxY - hoverHeight - 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
$hoverMenu.addClass('active')
|
$hoverMenu.addClass('active')
|
||||||
.html($hoverContent.html())
|
.html($hoverContent.html())
|
||||||
.css({ left: x, top: newY });
|
.css({ left: posX, top: posY });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#js-hover-menu").on("mouseleave", function () {
|
$hoverMenu.on('mouseleave', function () {
|
||||||
$("#js-hover-menu").removeClass("active");
|
$hoverMenu.removeClass('active');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function formatCurrency(a) {
|
function formatCurrency(a) {
|
||||||
var b = parseFloat(a).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1.").toString();
|
var b = parseFloat(a).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1.").toString();
|
||||||
var len = b.length;
|
var len = b.length;
|
||||||
|
|||||||
Reference in New Issue
Block a user