Skip to content

Commit fb183e6

Browse files
author
brou
committed
export only ResizeSensor
1 parent 812e3bb commit fb183e6

File tree

2 files changed

+5
-107
lines changed

2 files changed

+5
-107
lines changed

README.md

Lines changed: 4 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,10 @@
1-
# CSS Element Queries
1+
# CSS Resize Sensor
22

3+
## Warning
34

4-
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/marcj/css-element-queries?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
5+
This version is a quick-fixed version of [marcj's `css-element-queries`](https://github.com/marcj/css-element-queries) that only exports the ResizeSensor module.
56

6-
Element Queries is a polyfill adding support for element based media-queries to all new browsers (incl. IE7+).
7-
It allows not only to define media-queries based on window-size but also adds 'media-queries' functionality depending on element (any selector supported)
8-
size while not causing performance lags due to event based implementation.
9-
10-
It's a proof-of-concept event-based CSS element dimension query with valid CSS selector syntax.
11-
12-
Features:
13-
14-
- no performance issues since it listens only on size changes of elements that have element query rules defined through css. Other element query polifills only listen on `window.onresize` which causes performance issues and allows only to detect changes via window.resize event and not inside layout changes like css3 animation, :hover, DOM changes etc.
15-
- no interval/timeout detection. Truly event-based through integrated ResizeSensor class.
16-
- no CSS modifications. Valid CSS Syntax
17-
- all CSS selectors available. Uses regular attribute selector. No need to write rules in HTML.
18-
- supports and tested in webkit, gecko and IE(7/8/9/10/11)
19-
- `min-width`, `min-height`, `max-width` and `max-height` are supported so far
20-
- works with any layout modifications: HTML (innerHTML etc), inline styles, DOM mutation, CSS3 transitions, fluid layout changes (also percent changes), pseudo classes (:hover etc.), window resizes and more
21-
- no Javascript-Framework dependency (works with jQuery, Mootools, etc.)
22-
- Works beautiful for responsive images without FOUC
23-
24-
More demos and information: http://marcj.github.io/css-element-queries/
25-
26-
## Examples
27-
28-
### Element Query
29-
30-
```css
31-
.widget-name h2 {
32-
font-size: 12px;
33-
}
34-
35-
.widget-name[min-width~="400px"] h2 {
36-
font-size: 18px;
37-
}
38-
39-
.widget-name[min-width~="600px"] h2 {
40-
padding: 55px;
41-
text-align: center;
42-
font-size: 24px;
43-
}
44-
45-
.widget-name[min-width~="700px"] h2 {
46-
font-size: 34px;
47-
color: red;
48-
}
49-
```
50-
51-
As you can see we use the `~=` [attribute selector](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors).
52-
Since this css-element-queries polyfill adds new element attributes on the DOM element
53-
(`<div class="widget-name" min-width="400px 700px"></div>`) depending on your actual CSS,
54-
you should always use this attribute selector (especially if you have several element query rules on the same element).
55-
56-
```html
57-
<div class="widget-name">
58-
<h2>Element responsiveness FTW!</h2>
59-
</div>
60-
```
61-
62-
### Responsive image
63-
64-
```html
65-
<div data-responsive-image>
66-
<img data-src="http://placehold.it/350x150"/>
67-
<img min-width="350" data-src="http://placehold.it/700x300"/>
68-
<img min-width="700" data-src="http://placehold.it/1400x600"/>
69-
</div>
70-
```
71-
72-
Include the javascript files at the bottom and you're good to go. No custom javascript calls needed.
73-
74-
```html
75-
<script src="src/ResizeSensor.js"></script>
76-
<script src="src/ElementQueries.js"></script>
77-
```
78-
79-
## See it in action:
80-
81-
Here live http://marcj.github.io/css-element-queries/.
82-
83-
![Demo](http://marcj.github.io/css-element-queries/images/css-element-queries-demo.gif)
84-
85-
86-
## Module Loader
87-
88-
If you're using a module loader you need to trigger the event listening or initialization yourself:
89-
90-
```javascript
91-
var EQ = require('node_modules/css-element-queries/ElementQueries');
92-
93-
//attaches to DOMLoadContent
94-
EQ.listen();
95-
96-
//or if you want to trigger it yourself.
97-
// Parse all available CSS and attach ResizeSensor to those elements which have rules attached
98-
// (make sure this is called after 'load' event, because CSS files are not ready when domReady is fired.
99-
EQ.init();
100-
```
101-
102-
## Issues
103-
104-
- So far does not work on `img` and other elements that can't contain other elements. Wrapping with a `div` works fine though (See demo).
105-
- Adds additional hidden elements into selected target element and forces target element to be relative or absolute.
106-
- Local stylesheets do not work (using `file://` protocol).
7+
I am using this fork in combination with [ef4's `ember-browserify`](https://github.com/ef4/ember-browserify) to make it [`ember-cli`](http://ember-cli.com/) compatible.
1078

1089
## License
10910

index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
module.exports = {
2-
ResizeSensor: require('./src/ResizeSensor'),
3-
ElementQueries: require('./src/ElementQueries')
4-
};
1+
module.exports = require('./src/ResizeSensor') ;

0 commit comments

Comments
 (0)