Skip to content
This repository was archived by the owner on Jan 10, 2021. It is now read-only.

Commit 7465cd1

Browse files
Merge pull request #17 from dutchenkoOleg/master
0.5.1
2 parents a2f844e + 7a89e28 commit 7465cd1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1690
-476
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
/.idea/
2-
/node_modules/
1+
/.idea
2+
/node_modules
33
/package-lock.json

.npmignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/docs/
2-
/examples/
1+
/docs
32
/.eslintrc.json
3+
/resources
44
/rollup.config.js
55
/_config.yml

README.md

Lines changed: 5 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88
---
99

10-
### _**Status WIP**_
11-
12-
---
10+
![zz-load](https://repository-images.githubusercontent.com/160879073/eff5b180-7b4f-11e9-877d-c9b26c5007e0)
1311

1412
> _**Project inspired by [lozad.js](https://github.com/ApoorvSaxena/lozad.js)**_
1513
> _**Big thx to [ApoorvSaxena](https://github.com/ApoorvSaxena) and community for their work on `lozad.js`**_
@@ -36,202 +34,13 @@
3634
| `triggerLoad()` method return Promise | _No_ | _**Yes**_ |
3735

3836

39-
## Live preview
40-
41-
[https://WezomAgency.github.io/zz-load/examples/](https://wezomagency.github.io/zz-load/examples/index.html)
42-
43-
---
44-
45-
46-
# Install
47-
48-
#### NPM
49-
50-
```bash
51-
npm i zz-load
52-
```
53-
54-
#### CDN (unpkg.com)
55-
56-
```html
57-
<script src="https://unpkg.com/zz-load@latest/dist/zz-load.js"></script>
58-
<!-- or minimized version -->
59-
<script src="https://unpkg.com/zz-load@latest/dist/zz-load.min.js"></script>
60-
```
61-
62-
#### Download
63-
64-
- [zz-load.es.js](https://unpkg.com/zz-load@latest/zz-load.es.js)
65-
- [dist/zz-load.js](https://unpkg.com/zz-load@latest/dist/zz-load.js)
66-
- [dist/zz-load.min.js](https://unpkg.com/zz-load@latest/dist/zz-load.min.js)
67-
68-
---
69-
70-
# Simple usage
71-
72-
Prepare markup
73-
74-
```html
75-
<img class="zzload custom-image"
76-
width="150" height="150"
77-
src="./some-low-quality-placeholder.jpg"
78-
data-zzload-source-img="./path/to/image.jpg">
79-
```
80-
81-
CSS for transition
82-
83-
```css
84-
.custom-image {
85-
opacity: 0;
86-
}
87-
88-
/* zz-load will add `data-zzload-is-loaded` attribute
89-
after fully resource loaded */
90-
.custom-image[data-zzload-is-loaded] {
91-
opacity: 1;
92-
transition: opacity .3s ease;
93-
}
94-
```
95-
96-
97-
import js module
98-
99-
```js
100-
import zzLoad from 'zz-load';
101-
```
102-
103-
or include as external file
104-
105-
```html
106-
<script src="your/path/to/zz-load.min.js"></script>
107-
<!-- will be added to Window, as global object zzLoad -->
108-
```
109-
110-
then fire up
111-
112-
```js
113-
const observer = zzLoad();
114-
observer.observe();
115-
```
116-
117-
---
118-
119-
## More Examples
120-
121-
_documentation in progress_
122-
123-
---
124-
125-
# API
126-
127-
### `zzLoad([elements][, options]): observer`
128-
129-
#### `elements`
130-
131-
_type_: `string | Element | NodeList | jQuery<Element>`
132-
_default value_: `'.zzload'`
133-
134-
Can be elements or string selector for find elements.
135-
136-
13737

38+
## Docs and examples
13839

139-
#### `options`
140-
141-
_type:_ `Object`
142-
143-
##### `options.rootMargin`
144-
145-
_default value:_ `'0px'`
146-
read more: [IntersectionObserver.rootMargin](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin)
147-
148-
149-
150-
151-
##### `options.threshold`
152-
153-
_default value:_ `0`
154-
read more: [IntersectionObserver.thresholds](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/thresholds)
155-
156-
157-
158-
159-
160-
##### `options.onLoad(element, source): void`
161-
162-
_default value:_ `empty function`
163-
Callback executed on fully success loaded source.
164-
Has two arguments:
165-
166-
- `element: Element` - current element
167-
- `source: string` - loaded source url
168-
169-
example:
170-
171-
```js
172-
import zzLoad from 'zz-load';
173-
const observer = zzLoad('.zzload', {
174-
onLoad (element, source) {
175-
element.classList.add('is-fully-loaded');
176-
console.log('Source successfully loaded:\n' + source);
177-
}
178-
})
179-
```
180-
181-
182-
> _Note! zzLoad automatically will add own attribute to elements,_
183-
> _for marking them as loaded, even without setting custom `onLoad()` method._
184-
> _So you can use this approach for custom styling._
185-
> _Read more in [Auto marking elements](#auto-marking-elements) section_
186-
187-
188-
189-
190-
191-
192-
##### `options.onError(element, source): void`
193-
194-
_default value:_ `empty function`
195-
Callback executed on error loading source.
196-
Has two arguments:
197-
198-
- `element: Element` - current element
199-
- `source: string` - failed source url
200-
201-
example:
202-
203-
```js
204-
import zzLoad from 'zz-load';
205-
const observer = zzLoad('.zzload', {
206-
onError (element, source) {
207-
element.classList.add('is-damaged');
208-
console.warn('Something went wrong with source:\n' + source);
209-
}
210-
})
211-
```
212-
213-
214-
> _Note! zzLoad automatically will add own attribute to elements,_
215-
> _for marking them as failed, even without setting custom `onLoad()` method._
216-
> _So you can use this approach for custom styling._
217-
> _Read more in [Auto marking elements](#auto-marking-elements) section_
218-
219-
### `observer`
220-
221-
_documentation in progress_
222-
223-
#### `observer.observe()`
224-
225-
_documentation in progress_
226-
227-
#### `observer.triggerLoad(): Promise`
228-
229-
_documentation in progress_
230-
231-
---
40+
https://WezomAgency.github.io/zz-load/
23241

233-
# Auto marking elements
42+
## License
23443

235-
_documentation in progress_
44+
[MIT](https://github.com/WezomAgency/zz-load/blob/master/LICENSE)
23645

23746

_config.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)