flip icon indicating copy to clipboard operation
flip copied to clipboard

Window resize event + forceHeight

Open madeinua opened this issue 8 years ago • 1 comments

Hi there,

found a problem related to the card height when you resizing the window (e.g. rotate your phone/tablet from/to the landscape mode) + forceHeight: true option. The height of the card should be automatically changed depends on the content height. Currently it stays with the initial value.

Please implement some logic (e.g. window.resize) to solve this problem.

Thanks, Artem.

madeinua avatar Oct 24 '16 13:10 madeinua

I have a solution (depending the flip() is attached to .card):

(function ($) { /** * Custom plugin destroyer */ var destroyCrappyPlugin = function($elem, eventNamespace) { var isInstantiated = !! $.data($elem.get(0));

    if (isInstantiated) {
        $.removeData($elem.get(0));
        $elem.off(eventNamespace);
        $elem.unbind('.' + eventNamespace);
    }
};
/**
 * Clear all flippers
 */
function clearAllFlips() {
	$(".card").removeAttr("style");
    $(".card").find('*').each(function(){
    	$(this).removeAttr("style");
    });
}

/**
 * Initiate flippers
 */
$(window).load(function() {
	$(".card").flip({forceHeight: true});
});

/**
 * Reinitiate flippers on window resize
 */
$(window).resize(function(){
    $(".card").each(function() {
    	destroyCrappyPlugin($(this), 'flip');
    });
	clearAllFlips();
    $(".card").flip({forceHeight: true});
});

}(jQuery));

Alluuu avatar Dec 05 '16 22:12 Alluuu