I am looking for a jQuery
plugin to expand div
elements so as to reveal their overflow (if any) on hover. Illustration:
If it is text, it is a little more complicated...
I use it like this:
$('.floating').mouseenter(function(){
const $this = $(this);
const dimension = $this.data('dimension');
const ratioEnlarged = 2;
const tempElement = $this.clone();
tempElement.appendTo('body');
tempElement.css({
width: dimension.width,
height: dimension.height
});
if(tempElement.is(':offscreen')){
// Change this to animate if you want it animated.
$this.css({
'margin-left': -dimension.width * ratioEnlarged/2,
'margin-top': -dimension.height * ratioEnlarged/4,
'font-size': ratioEnlarged + 'em',
width: dimension.width * ratioEnlarged,
height: dimension.height * ratioEnlarged
});
} else {
$this.css({
'margin-left': -dimension.width * ratioEnlarged/4,
'margin-top': -dimension.height * ratioEnlarged/4,
'font-size': ratioEnlarged + 'em',
width: dimension.width * ratioEnlarged,
height: dimension.height * ratioEnlarged
});
}
tempElement.remove();
});
$('.floating').mouseleave(function(event) {
const $this = $(this);
const dimension = $this.data('dimension');
if(!$this.hasClass('context-menu-active')){
$this.css({
margin: 0,
'font-size': '1em',
width: dimension.width,
height: dimension.height
});
}
});