├── README.md
├── app.html
├── app.js
├── css
├── loading.css
└── main.css
├── fonts
├── Electrolize.woff
└── Electrolize.woff2
├── img
├── bg1.jpg
├── loader-light.png
└── screen.jpg
└── index.html
/README.md:
--------------------------------------------------------------------------------
1 | # Frosted Panel [](https://twitter.com/intent/tweet?text=Frosted%20Glass%2FPanel%20Effect%2C%20Cross%20Browser%2C%20%28Vainlla%20JS%20%26%20CSS%29&url=https://github.com/cryptodescriptor/frosted-panel&hashtags=css,javascript,design,frostedglass,frostedpanel,effect)
2 |
3 | Frosted Panel is a cross-browser compatible library written in pure Javascript to achieve a responsive "Frosted Glass" effect.
4 |
5 |
6 |
7 | If you are trying to get the same effect [documented here](https://webdesign.tutsplus.com/tutorials/how-to-create-a-frosted-glass-effect-in-css--cms-32535), but need it to work on as many browsers as possible, even if they do not support `filter: blur()`, then Frosted Panel is the library for you.
8 |
9 | Check out the [live demo](https://cryptodescriptor.github.io/frosted-panel) so you can see a demonstration of what it looks like. Try re-sizing the browser to see the panels responsiveness.
10 |
11 | Browsers tested thus far:
12 |
13 | - Chrome
14 | - Firefox
15 | - Firefox Focus
16 | - Edge
17 | - Internet Explorer
18 | - Safari
19 | - Opera
20 |
21 | Although only a few browsers are listed above, it should work on the majority of them. The goal of this library is to be as compatible with as many browsers as possible.
22 |
23 |
24 | ## Getting Started
25 |
26 | To get started, you will need to fork this repository or [download as zip](https://github.com/cryptodescriptor/frosted-panel/archive/master.zip).
27 |
28 |
29 | ## Configuration
30 |
31 | Firstly, you will need to select the background-image you want to use. Frosted Panel now scales the image using `background-size: cover` as of BETA_v1.1, therefore the image size is no longer as relevant, we just recommend sizing to be at least `1920x1080` for optimal quality. You may wish to go even larger if you want it to look crisp on 4k monitors, but it will scale nonetheless.
32 |
33 | Now that you know what image you will be using, you must specify the path inside `app.html` on the attribute `xlink:href` of the `image` element. Please also change the `width` and `height` attributes to match the dimensions of your image. If you are using an image of `2880x1620` pixels, the `width` should have a value of `2880` and the `height` should have a value of `1620`.
34 |
35 |
36 |
37 |
38 | ## Attributes
39 |
40 | Now you have your background-image all set up, you need to configure the panel size, its margins, and optionally add some breakpoints to allow you to change the sizing on different viewports.
41 |
42 | For simplicity, Frosted Panel is configured using html attributes only.
43 |
44 |
45 | ## Width & Height
46 |
47 | To set the `width` and `height` of the panel, you need to set the `panel-dimensions` attribute on the div with the class `frosted-panel`.
48 |
49 |
50 |
51 | The `width` is the first value, and the `height` is the second value, **the two values should be delimited by a single space**.
52 |
53 | Values can be one of three types: `px`, `%`, `auto`:
54 |
55 |
56 | |Type| Description |
57 | |--|--|
58 | | px | Fixed size in pixels |
59 | | % | Percentage of viewport width or height |
60 | | auto | Auto width or height based on content size |
61 |
62 |
63 | ## Content & Content Margin
64 |
65 | All the content that you wish to be inside the panel, must be nested within the `content` div. If you want to control the margin around the content (the space between the content and the edge of the panel), then you must do so by setting `content-margin` attribute on the div, with a pixel value. If this attribute is missing or empty, then the margin will default to 0.
66 |
67 |
68 |
69 |
70 | ## Appending Content
71 |
72 | **As of BETA_v2.1 this should no longer be necessary!**
73 |
74 | If you plan to append content to the panel programmatically, after you do so, you will need to call:
75 |
76 | frostedPanel.pan_and_zoom()
77 |
78 | To re-calculate the `width` and `height` if they are set to `auto`.
79 |
80 | ## Panel Margin
81 |
82 | On the `body` tag, you can add an optional attribute `space-top-bot`, which works by setting `min-height` of the page to a value of `panel_height + (space-top-bot*2)`, every time the screen is resized. This allows us to emulate a top and bottom `margin` for our panel. Currently there is no way to set a left and right margin, I didn't add this feature because generally you will be using percentage width's for your panel anyway.
83 |
84 | If you do use fixed width's, make sure the panel `width` is small enough to fit on the viewport's of your website visitors, otherwise the panel will overflow the body.
85 |
86 |
87 |
88 | The above code will add 50px top margin and 50px bottom margin.
89 |
90 |
91 | ## Blur Amount (stdDeviation)
92 | To adjust the "blurryness" of the panel, you will need to change the value of `stdDeviation` attribute (nested inside the `filter` element of the `svg`). The higher the number, the more blurry your panel will be.
93 |
94 |
95 |
96 |
97 | ## Breakpoints
98 |
99 | You can configure the panel to be different sizes at different viewport width's using the `breakpoints` attribute in conjunction with `breakpoint-type` attribute.
100 |
101 | You should be familiar with CSS media queries that make use of `min-width` and `max-width` conditions to apply a set of styles at certain viewport width's (breakpoints).
102 |
103 | Frosted Panel gives you freedom of choice by allowing you to provide `breakpoint-type` attribute, with a value of either `min-width` (mobile first), or `max-width`. The performance impact will be exactly the same for both, just use the one you feel the most comfortable with.
104 |
105 | Example:
106 |
107 |
108 |
109 | Great! Now you have selected which media query type you will be using, you can start to tell Frosted Panel how big you want it to be at different viewport width's.
110 |
111 | You do this by passing a list of breakpoints to the `breakpoints` attribute, each delimited by a single comma `,`.
112 |
113 | Each breakpoint must follow a specific format. The first value is the `width` in pixels that you want the breakpoint to occur at (must end with "`px`"), the second and third values are `width` and `height` values which determine the size of the panel when the breakpoint is triggered. The `width` and `height` value's each can be one of three format's described in the "Width & Height" section.
114 |
115 | Examples:
116 |
117 |
118 |
119 | The CSS equivalent of the above would be:
120 |
121 | .frosted-panel {
122 | width: auto;
123 | height: auto;
124 | }
125 |
126 | @media only screen and (min-width: 600px) {
127 | .frosted-panel {
128 | width: 70%;
129 | height: 300px;
130 | }
131 | }
132 |
133 | @media only screen and (min-width: 1200px) {
134 | .frosted-panel {
135 | width: 60%;
136 | height: 500px;
137 | }
138 | }
139 |
140 | When `breakpoint-type` is changed from `min-width` to `max-width`, the CSS equivalent would now be this:
141 |
142 | .frosted-panel {
143 | width: auto;
144 | height: auto;
145 | }
146 |
147 | @media only screen and (max-width: 1200px) {
148 | .frosted-panel {
149 | width: 60%;
150 | height: 500px;
151 | }
152 | }
153 |
154 | @media only screen and (max-width: 600px) {
155 | .frosted-panel {
156 | width: 70%;
157 | height: 300px;
158 | }
159 | }
160 |
161 | As you can see, the breakpoint attributes emulate standard CSS media queries. And are mandatory if you wish to use media queries to control the size of Frosted Panel.
162 |
--------------------------------------------------------------------------------
/app.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Frosted Panel Demo
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
25 |
26 |
27 |