HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers96/smilefotografie.nl/wwwroot/js/app/core/images.js
define('core/images',[],function()
{
    return {
        initialize: function()
        {
            var t = this;

            t.fill();
            t.fit();
            t.preload();

            $(window).resize(function()
            {
                t.fill();
                t.fit();
            });
        },

        fill : function()
        {
            $('img.fill').one('load',function()
            {
                // Sizes
                var w = $(this).width();
                var h = $(this).height();
                var pw = $(this).parent().width();
                var ph = $(this).parent().height();
                var ratio = w/h;

                var css = {};

                // Check new with
                if( ratio < (pw/ph))
                {
                    css.width = pw;
                    css.height = pw / ratio;
                }
                else
                {
                    css.height = ph;
                    css.width = ph * ratio;
                }


                css.marginLeft = (css.width / -2) + 'px';
                css.marginTop = (css.height / -2) + 'px';

                css.left = '50%';
                css.top = '50%';

                $(this).css(css);

            }).each(function()
            {
                if(this.complete) $(this).load();
            });
        },

        fit : function()
        {
            $('img.fit').one('load',function()
            {
                // Sizes
                var w = $(this).width();
                var h = $(this).height();
                var pw = $(this).parent().width();
                var ph = $(this).parent().height();
                var ratio = w/h;

                var css = {};

                // Check new with
                if( ratio < (pw/ph))
                {
                    css.height = ph;
                    css.width = ph * ratio;

                }
                else
                {
                    css.width = pw;
                    css.height = pw / ratio;
                }


                css.marginLeft = (css.width / -2) + 'px';
                css.marginTop = (css.height / -2) + 'px';

                css.left = '50%';
                css.top = '50%';

                $(this).css(css);

            }).each(function()
            {
                if(this.complete) $(this).load();
            });
        },


        preload: function()
        {
            $('img.preload').one('load',function()
            {
                $(this).addClass('loaded');
            }).each(function()
            {
                if(this.complete) $(this).load();
            });
        }

    }
});