Example #1
0
        protected static ScreenWidth CalculateScreenWidth()
        {
            int width = IsContextCookiePresent ? ContextEngine.GetClaims <BrowserClaims>().DisplayWidth : 1024;

            if (width < SiteConfiguration.MediaHelper.SmallScreenBreakpoint)
            {
                return(ScreenWidth.ExtraSmall);
            }
            if (width < SiteConfiguration.MediaHelper.MediumScreenBreakpoint)
            {
                return(ScreenWidth.Small);
            }
            if (width < SiteConfiguration.MediaHelper.LargeScreenBreakpoint)
            {
                return(ScreenWidth.Medium);
            }
            return(ScreenWidth.Large);
        }
        protected static ScreenWidth CalculateScreenWidth()
        {
            int width = IsContextCookiePresent ? ContextEngine.GetClaims <BrowserClaims>().DisplayWidth : MaxWidth;

            // zero width is not valid and probably means the context engine was not correctly initialized so
            // again default to 1024
            if (width == 0)
            {
                width = MaxWidth;
            }
            if (width < SiteConfiguration.MediaHelper.SmallScreenBreakpoint)
            {
                return(ScreenWidth.ExtraSmall);
            }
            if (width < SiteConfiguration.MediaHelper.MediumScreenBreakpoint)
            {
                return(ScreenWidth.Small);
            }
            if (width < SiteConfiguration.MediaHelper.LargeScreenBreakpoint)
            {
                return(ScreenWidth.Medium);
            }
            return(ScreenWidth.Large);
        }